Boost logo

Boost :

Subject: [boost] [thread] boost::shared_mutex vs. pthread_rwlock_unlock
From: Rush Manbert (rush_at_[hidden])
Date: 2009-05-01 14:56:07


I am replacing a pthread threading implementation with a boost threads
implementation so I can use the code on Windows.

There is a ReadWriteMutex class that has the following declaration:

class ReadWriteMutex {
public:
   ReadWriteMutex();
   virtual ~ReadWriteMutex() {}

   // these get the lock and block until it is done successfully
   virtual void acquireRead() const;
   virtual void acquireWrite() const;

   // these attempt to get the lock, returning false immediately if
they fail
   virtual bool attemptRead() const;
   virtual bool attemptWrite() const;

   // this releases both read and write locks
   virtual void release() const;

private:

   class impl;
   boost::shared_ptr<impl> impl_;
};

Note the release() method that works for a thread that holds either
the read or write lock.

My implementation uses boost::shared_mutex.
acquireRead calls lock_shared(),
acquireWrite calls lock(),
attemptRead calls try_lock_shared(),
attemptWrite calls try_lock,

and

release calls ???????

AFAICT there is no equivalent to the pthread_rwlock_unlock() call that
the original version of release() called.

Am I missing something?

Thanks,
Rush


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