]> git.lizzy.rs Git - rust.git/commit
Implement reentrant mutexes and make stdio use them
authorSimonas Kazlauskas <git@kazlauskas.me>
Fri, 3 Apr 2015 21:46:54 +0000 (00:46 +0300)
committerSimonas Kazlauskas <git@kazlauskas.me>
Wed, 8 Apr 2015 16:42:16 +0000 (19:42 +0300)
commit45aa6c8d1bc2f7863c92da6643de4642bb2d83bf
tree53f8648a696dc49072ceef53c36974f6fc599515
parent80def6c2447d23a624e611417f24cf0ab2a5a676
Implement reentrant mutexes and make stdio use them

write_fmt calls write for each formatted field. The default implementation of write_fmt is used,
which will call write on not-yet-locked stdout (and write locking after), therefore making print!
in multithreaded environment still interleave contents of two separate prints.

This patch implements reentrant mutexes, changes stdio handles to use these mutexes and overrides
write_fmt to lock the stdio handle for the whole duration of the call.
14 files changed:
src/libstd/io/stdio.rs
src/libstd/sync/condvar.rs
src/libstd/sync/mod.rs
src/libstd/sync/mutex.rs
src/libstd/sync/poison.rs [deleted file]
src/libstd/sync/rwlock.rs
src/libstd/sys/common/mod.rs
src/libstd/sys/common/poison.rs [new file with mode: 0644]
src/libstd/sys/common/remutex.rs [new file with mode: 0644]
src/libstd/sys/unix/mutex.rs
src/libstd/sys/unix/sync.rs
src/libstd/sys/windows/mutex.rs
src/libstd/sys/windows/sync.rs
src/test/run-pass/atomic-print.rs [new file with mode: 0644]