Boost logo

Threads-Devel :

From: Anthony Williams (anthony_at_[hidden])
Date: 2006-03-01 11:50:44


Matt Hurd <matt.hurd_at_[hidden]> writes:

>> Hi all,
> <snip>
>
> An additional discussion point is the recursive / non-recursive default
> thingo.
>
> I like the current boost default of a boost::mutex being the base level an
> platform supports, but this has bitten me big time in projects. Especially
> with windows developers coming to a posix platform.
>
> Posix, and thus linux, are non-recursive by default. Windows mutexes are
> re-entrant.
>
> I'm no longer so sure the boost default is such a good idea especially as the
> performance of a recursive mutex on posix on a modern platform seems
> consistent with a non-recursive one in the main...
>
> I think having the recursive mutex as a consisent default across platforms
> will be a good thing and protect the average user, like me, from themselves.
>
> Have a concept of a non-recursive mutex as a special case mutex raises an
> interesting point as on windows they don't exist, so the separate concept as
> a
> lowest_level_mutex_that_may_be_recursive_or_non_recursive_depending_on_your_platform
> which is the boost default remains useful.
>
> Any thoughts on this?

Well, OS Mutexes might be recursive on Windows, but Critical Sections
aren't. My basic_mutex isn't, for the same reason Critical Sections aren't ---
in the absence of contention, it's just a straightforward interlocked
increment, and making it recursive requires additional code --- hence my
basic_recursive_mutex.

I think that separating recursive and non-recursive mutexes is a good idea.

Anthony

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

Threads-Devel list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk