Thread Safety in the Standard C++ Library
2019獨角獸企業重金招聘Python工程師標準>>>
Thread Safety in the Standard C++ Library
When? /MT , /MTd, /MD, or /MDd is used, the following thread-safety rules are in effect:Container Classes (vector, deque, list, queue, stack , priority_queue, valarray, map, multimap, set, multiset, basic_string, bitset) and complex
For reads to the same object, the object is thread safe for reading:
- From one thread at a time when no writers on other threads.
- From many threads at a time when no writers on other threads.
For writes to the same object, the object is thread safe for writing from one thread when no readers on other threads
For reads to different objects of the same class, the object is thread safe for reading:
- From one thread at a time.
- From one thread at a time when no writers on other threads.
- From many threads at a time.
- From many threads at a time when no writers on other threads.
For writes to different objects of the same class, the object is thread safe for writing:
- From one thread when no readers on other threads.
- From many threads.
iostream Classes
Note that reading from a stream buffer is not considered to be a read operation. It should be considered as a write operation, because this changes the state of the class.
For reads to the same object, the object is thread safe for reading:
- From one thread at a time when no writers on other threads.
- From many threads at a time when no writers on other threads.
For writes to the same object, , the object is thread safe for writing:
- From one thread when no readers on other threads.
- From many threads (when accesses are limited to stream buffers).
For reads to different objects of the same class, , the object is thread safe for reading:
- From one thread at a time.
- From one thread at a time when no writers on other threads.
- From many threads at a time.
- From many threads at a time when no writers on other threads.
For writes to different objects of the same class, the object is thread safe for writing:
- From one thread when no readers on other threads
- From many threads
轉載于:https://my.oschina.net/u/230229/blog/110067
總結
以上是生活随笔為你收集整理的Thread Safety in the Standard C++ Library的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 在路由器使用ACL防止IP地址欺骗
- 下一篇: XenApp Farm:修改密码、退域、