boost::details::pool::pthread_mutex and boost::details::pool
boost::details::pool::pthread_mutex and boost::details::pool::null_mutex
boost::details::pool::pthread_mutex
和boost::details::pool::null_mutex
有什么区别。
我看到在最新的提升版本 - 1.42 中,类boost::details::pool::pthread_mutex
被删除了。我应该改用什么?
boost::details::pool::null_mutex
是一个互斥锁,什么都不做(锁总是立即成功)。 当您不使用线程时,这是合适的。 Boost 池库根据 boostpooldetailmutex.hpp
中的以下代码片段,选择它将使用哪种类型的互斥锁来同步对关键部分的访问与互斥锁类型的 typedef:
#if !defined(BOOST_HAS_THREADS) || defined(BOOST_NO_MT) || defined(BOOST_POOL_NO_MT)
typedef null_mutex default_mutex;
#else
typedef boost::mutex default_mutex;
#endif
换句话说,如果配置说不涉及线程(无论是对于整个 Boost,还是特别是对于池库),那么将使用null_mutex
(这基本上是一个 nop)。
如果要支持线程,则将使用 boost::mutex
类型,该类型来自 Boost 线程库(如果您的系统使用 pthreads,它将是基于 pthread的互斥锁)。
相关文章:
- 理解boost::asio-async_read在无需读取内容时的行为
- boost::进程间消息队列引发错误
- 如何运行位于boost/libs/python/example/tutorial目录中的hello.cpp和Jamfil
- cmake如何在fedora工作站中找到boost静态库包
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- Boost Graph Library,修复节点大小
- C++Boost Asio Pool线程,带有lambda函数和传递引用变量
- 是否可以使用Boost ::或Boost ::变体带有boost :: pool
- boost::asio io_service thread pool with io_service::work
- 使用boost :: pool时使用高CPU
- 在VS2010中使用Boost.Pool - 链接器错误
- boost::details::pool::pthread_mutex and boost::details::pool
- 如何使用boost.pool来实现类似stl映射的映射
- boost::threadpool::pool vs.boost::thread_group
- 使用boost::pool管理std::vector中的内存分配
- boost::asio io_service thread pool
- Boost::pool默认的chunk数量
- boost.pool如何实现已分配内存的重用
- 除了boost::pool之外,C++中的自定义池分配器
- 使用 boost.pool 而不是 'new' 作为对象的容器