Boost Mutex implementation for Windows(Windows 的 Boost Mutex 实现)
问题描述
据我所知,在旧版本的 Boost boost::mutex
中,Windows 的实现是使用临界区完成的.但是在 Boost 1.51 的最新版本中,我发现现在互斥锁的实现是基于事件的.
As far as I know in old versions of Boost boost::mutex
implementation for Windows was done using critical sections. But in the newest version of Boost 1.51 I discovered that now mutex implementation is based on Events.
有人知道这种变化背后的原因是什么吗?是因为性能原因吗?临界区会被弃用吗?
Does anybody know what is the rational behind this change? Was it done because of performance reasons? Do critical sections become deprecated?
推荐答案
通过使用 boost
,我们总是有最好的方法而不做任何改变,这不是很好吗?在新版本的 boost
中,boost::mutex
被实现为一个自旋锁,但在 Windows 事件的帮助下避免忙等待,并且该事件只会在需要时创建,因此它非常轻量级并且具有非常高的性能并且还使 boost
能够使用这个轻量级的 mutex
进行定时等待!我觉得这个很棒
Isn't it wonderful that by using boost
we always have best approach with no change?
In new version of boost
, boost::mutex
is implemented as an spinlock but with the help of a windows event to avoid busy wait and that event will only created if needed, thus it is very light weight and have a very high performance and also enable boost
to use this light weight mutex
for timed wait! I think this is excellent
这篇关于Windows 的 Boost Mutex 实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Windows 的 Boost Mutex 实现


- C++ 协变模板 2021-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- 从python回调到c++的选项 2022-11-16
- STL 中有 dereference_iterator 吗? 2022-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- 近似搜索的工作原理 2021-01-01
- 静态初始化顺序失败 2022-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01