Boost logo

Boost :

Subject: Re: [boost] Performance characteristics of Boost mutex
From: Peter Dimov (lists_at_[hidden])
Date: 2014-10-17 16:34:21

Philip Bennefall wrote:
> Hi all,
> I am detecting some lock contention in my application, and while reading
> up on this I came across the concept of lightweight mutexes versus
> supposedly non-lightweight mutexes. I am wondering, can Boosts
> non-recursive mutex implementation be considered lightweight? In
> boost/detail I see lightweight_mutex. Should I be using that?

Probably not.

detail::lightweight_mutex is merely a thin wrapper over CRITICAL_SECTION on
Windows and pthread_mutex on POSIX. It's "lightweight" only in the sense
that it doesn't require the user to link against a library (Boost.Thread).

In general, it doesn't make much sense to talk about a "lightweight" mutex
if you're talking performance. The "weight" of the mutex doesn't - in
general - have much to do with its performance (nowadays).

Boost list run by bdawes at, gregod at, cpdaniel at, john at