读者/作者锁定在C ++ [英] Reader/Writer Locks in C++

查看:143
本文介绍了读者/作者锁定在C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C ++中寻找一个好的读写器锁。我们有一个单一的不常见的作家和许多频繁读者的用例,并希望优化这一点。首选我想要一个跨平台的解决方案,然而一个Windows只有一个是可以接受的。

I'm looking for a good reader/writer lock in C++. We have a use case of a single infrequent writer and many frequent readers and would like to optimize for this. Preferable I would like a cross-platform solution, however a Windows only one would be acceptable.

推荐答案

更新版本的 boost::thread 有读/写锁(1.35.0及更高版本,显然以前的版本无法正常工作)。

Newer versions of boost::thread have read/write locks (1.35.0 and later, apparently the previous versions did not work correctly).

它们的名称为 shared_lock unique_lock upgrade_lock ,并操作 shared_mutex

They have the names shared_lock, unique_lock, and upgrade_lock and operate on a shared_mutex.

这篇关于读者/作者锁定在C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆