Boost logo

Boost :

From: Dirk Gerrits (dirkg_at_[hidden])
Date: 2002-05-17 08:06:24


----- Original Message -----
From: "Darryl Green" <green_at_[hidden]>
> The ability to lock and unlock in different scopes is required to
> implement a lockingptr<>.

As I mentioned in this thread before, I'm a newbie at multithreading,
so forgive me if I'm WAY off track here. But isn't it possible to
create a lockingptr using the following class data members:

mutex& mutex;
auto_ptr<mutex::scoped_lock> lock;
T* pointee;

The mutex& would be initialized by the constructor, as would the
T*. Locking is then:
if (lock.get() == 0)
    lock.reset(new mutex::scoped_lock(mutex));
Unlocking is:
lock.reset(0);

I'm not totally sure what public interface lockingptr would require
but would the above be enough to implement it? Or did I perhaps
misunderstand the whole lockingptr-thing?

Dirk Gerrits


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