用于c ++ 11线程的RW锁 [英] A RW lock for c++11 threads
问题描述
我想使用新的标准线程,而不是boost:线程,但我注意到旧的shared_mutex不可用。
I'd like to use the new standard threads instead of boost:threads but I've noticed the old shared_mutex is not available. What would be a good recommendation to replace this functionality and give me a multiple-readers, single-writer lock?
推荐答案
std :: shared_mutex
将是C ++ 14标准库的一部分。
std::shared_mutex
will be part of the C++14 Standard Library. It did not make it to C++11 just because there was no time to formulate a proposal and discuss it thoroughly.
你仍然可以使用,因为它没有时间来创建一个提案, boost :: shared_mutex
虽然。在Windows下,如果您使用的是Windows Vista或更高版本,则可以使用 Slim读写锁定,它们针对速度和内存消耗进行了优化。
You can still use boost::shared_mutex
though. Under Windows, if you are working with Windows Vista or later, you can use Slim Read-Write Locks, which are optimized for speed and memory consumption.
这篇关于用于c ++ 11线程的RW锁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!