Boost logo

Boost :

From: alnsn_at_[hidden]
Date: 2004-07-07 15:59:21

Eric Niebler wrote:
> if( ScopedLock l = try_lock( m ) )
> {
> }
> where try_lock is function that returns a simple wrapper class:

I prefer ScopedGuard-like implementation because it doesn't introduce
neither new try_lock function nor its return type (return type is
somewhat similar to lock class for new users yet is very different
from the lock because, for example, it's CopyConstructible => source of
If the code above were based on that idiom, try_lock/timed_lock/whatever_lock
classes could be "reused". On the one hand, they could be used for
standalone guards, on the other hand, it could be possible to compile
your code.
Of course, ScopedLock has to be const reference to some base class of
all lock classes.

Alexander Nasonov

Boost list run by bdawes at, gregod at, cpdaniel at, john at