From: Russell Hind (rhind_at_[hidden])
Date: 2003-04-23 04:33:03


thread currently allows various mutex implementations: I currently use
boost::mutex and boost::recursive_mutex most often. On Win32
boost::mutex is implemented using a CriticalSection. AFAIK, this is
recursively enterable. recursive_mutex also uses a critical section,
although with a little extra in the implementation.

I was wondering if there was a way to stop mutex being recursive on
Win32? I then looked into the source and saw that try_mutex uses a
Mutex, not a critical section. Would this implementation not work for
mutex?

Also, it appears that try_mutex uses a Mutex so that it can perform a
wait with a timeout of 0 (ie. if it can't enter, return immediately).
Could this not have been implemented with a critical section and use
TryEnterCriticalSection? Why was the mutex approach used for one and
not the other?

Thanks

Russell