Subject: Re: [boost] Performance characteristics of Boost mutex
From: Peter Dimov (lists_at_[hidden])
Date: 2014-10-17 18:44:56
Philip Bennefall wrote:
> Hi Peter,
> I see that Boost thread, since a few years ago from what I can tell, has
> its own mutex implementation based on a Windows event where as before it
> merely used critical sections. I am curious to know what the reasoning
> behind this change was?
CRITICAL_SECTIONs do not provide timed locking, and did not, at the time,
provide try-lock (TryEnterCriticalSection was not available on pre-XP, and
pre-XP platforms were still important in those days.) In addition,
Boost.Thread's alternative implementation was, at the time, actually
superior in performance to Windows's one.
Today, the built-in CRITICAL_SECTION in Vista/7/8 can probably hold its own,
and the slim reader-writer lock in exclusive mode will likely be a very good
performer as well.
(CRITICAL_SECTION is also recursive, which may not be a good choice for a
non-recursive mutex, even though it's technically allowed.)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk