|
Threads-Devel : |
From: Anthony Williams (anthony_at_[hidden])
Date: 2006-03-06 04:35:26
David Abrahams <dave_at_[hidden]> writes:
> Matt Hurd <matt.hurd_at_[hidden]> writes:
>
>> The current models supported by boost are:
>>
>> boost::mutex::scoped_lock
>> boost::recursive_mutex::scoped_lock
>> boost::try_mutex::scoped_lock
>> boost::recursive_try_mutex::scoped_lock
>> boost::timed_mutex::scoped_lock
>> boost::recursive_timed_mutex::scoped_lock
>> boost::try_mutex::scoped_try_lock
>> boost::recursive_try_mutex::scoped_try_lock
>> boost::timed_mutex::scoped_try_lock
>> boost::recursive_timed_mutex::scoped_try_lock
>> boost::timed_mutex::scoped_timed_lock
>> boost::recursive_timed_mutex::scoped_timed_lock
>>
>> Such specification is crying out for a different, policy like interface.
>
> Why?
boost::scoped_lock<boost::mutex>
boost::scoped_lock<boost::try_mutex>
boost::scoped_lock<boost::timed_mutex>
boost::scoped_lock<boost::recursive_mutex>
boost::scoped_lock<boost::recursive_try_mutex>
boost::scoped_lock<boost::recursive_timed_mutex>
boost::scoped_try_lock<boost::try_mutex>
boost::scoped_try_lock<boost::timed_mutex>
boost::scoped_try_lock<boost::recursive_try_mutex>
boost::scoped_try_lock<boost::recursive_timed_mutex>
boost::scoped_timed_lock<boost::timed_mutex>
boost::scoped_timed_lock<boost::recursive_timed_mutex>
Would seem cleaner to me. Yes, the lock implementation depends on the mutex
type, but it avoids duplication. IIRC, the current/old boost threads
implementation does exactly this under the covers, relying on some kind of
lock_traits stuff. I think it would make sense to expose this to the users.
Of course, if you tried to compile boost::scoped_timed_lock<boost::mutex>,
then this would fail to compile.
Anthony
-- Anthony Williams Software Developer Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk