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.
Showing
src/libstd/sys/common/remutex.rs
0 → 100644
src/test/run-pass/atomic-print.rs
0 → 100644
想要评论请 注册 或 登录