Boost logo

Boost :

From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2006-10-30 06:36:55


Roland Schwarz <roland.schwarz_at_[hidden]> writes:

> Anthony Williams wrote:
>> Windows named mutexes do give you exactly this functionality, though as they
>> are kernel objects you don't get the "fast path" options of a roll-your-own
>> mutex.

> But I want to show the differences. In my case I simply use the
> standard" process-local mutex, but wrapping it into a "name-generator".
>
> Consequently my approach gives you a fast-pathed mutex if you need it,
> without loss of the "named" feature.

Yes, agreed.

In practical terms, the only problems with your scheme are:

* Ensuring the that these "named" mutexes are correctly destroyed at process
termination, if people don't "close" the mutex. Maybe not an issue.

* Contention on the map. Ideally we don't want to have any contention for
unrelated mutexes. Chris Thomasson has suggested using a global lock-free
hashmap for this sort of thing.

Anthony

-- 
Anthony Williams
Software Developer
Just Software Solutions Ltd
http://www.justsoftwaresolutions.co.uk

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk