
On Sunday 28 September 2008 04:29, Anthony Williams wrote:
No. boost::mutex is a lightweight mutex. It has slightly different performance characteristics than CRITICAL_SECTION: it is intended to be "better" than CRITICAL_SECTION.
If not so, what's the reason for boost::detail::lightweight_mutex to exist ?
I think it's a historic artifact from versions of boost.thread prior to 1.35.0 when boost::mutex required linking to the thread library, which allowed mutexes to be used in header-only boost libraries.
I didn't realize boost::mutex was header-only now. I recently put a modified version of detail::lightweight_mutex (conforming to the Boost.Thread Lockable concept) into thread_safe_signals svn. I wanted header-only, plus it compiles to no-op when thread support is disabled/not present. Unfortunately, I also had to add a little unique_lock fill-in because boost/thread/locks.hpp still requires linking, due to the definition of the lock_error exception.