开发者

CRITICAL_SECTION in boost?

开发者 https://www.devze.com 2023-03-03 22:37 出处:网络
is there something in boost th开发者_开发知识库at translates to windows CRITICAL_SECTION? CRITICAL_SECTION is a so called \"user mode\" mutex that uses spin locks instead of blocking and avoids expens

is there something in boost th开发者_开发知识库at translates to windows CRITICAL_SECTION?

CRITICAL_SECTION is a so called "user mode" mutex that uses spin locks instead of blocking and avoids expensive transitions to the kernel.


Boost::Mutex is what you want, versions up to 1.34.1 used a win32 critical section, but new ones use a win32 event and locks. I don't know why - win32 mutexes are perfectly fine and as fast as an event (surely, he said...) unless you don't know if you need the crossprocess capability of them, or the sole-process limitation of a critical_section.

That said, chances are the performance implications of locking are mainly down to losing the rest of your threrad quantum, not necessarily kernel transitions.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号