Boost logo

Boost :

From: Bardur Arantsson (spam_at_[hidden])
Date: 2006-06-08 18:05:38


jmzorko_at_[hidden] wrote:
> Hello, all ...
>
> I'm trying to wrap boost::mutex::scoped_lock in another class that
> hides all of the boosty things:
>
> class Lock
> {
> public:
>
> Lock();
> ~Lock();
>
> private:
>
> boost::mutex mutex;
> boost::mutex::scoped_lock lock;
> };
>

Um. Maybe I'm missing something here, but this doesn't make any sense to
me at all. The whole point of scoped_lock is that the lifetime of the
mutex and scoped_lock lifetimes are *different*. Furthermore, you're not
actually locking anything with your Lock class... you'd simply get a
different mutex for each instance of Lock you create.

In short: You'd need two wrapper classes, one for scoped_lock and one
for mutex. Which means you might as well just use boost::mutex and
boost::scoped_lock.

Cheers,

-- 
Bardur Arantsson
<bardurREMOVE_at_[hidden]>
- That which does not kill you only makes you stranger.
                                MisterQueue @ http://kuro5hin.org

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