Boost logo

Boost :

From: jsiek_at_[hidden]
Date: 2000-08-11 07:22:43


Mark Rodgers writes:
> From: "Kevlin Henney" <kevlin_at_[hidden]>
> > There is no reason for the scoped guard class to be nested: this reduces
> > the (re)usabilty of such classes. The scoped guard class I have in mind
> > is external and templated on anything that is lockable. This has the
> > benefit of (1) being more generic and (2) reduces the code required to
> > write a synchronised class.
>
> That may be a convenient implementation of the guard for some synchronised
> objects; others might have different implementation requirements. Thus
> we might see
>
> struct YourMutex {
> typedef boost::lock_implementation<YourMutex> lock;
> ...
> };

I agree. The templated guard class is fine for implementation, but it
shouldn't be hard coded into the concept requirements, hence the
nested typedef. One reason for this is that we don't want to add
lock()/unlock() expressions to the Mutex concept. If those functions
exist, users will gravitate towards them instead of using the guard.

Ciao,

Jeremy


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