Reader/Writer Mutex

Hi everyone, Below you can see my simple thread safe class which allows multiple readers and exclusive write for single writer. Is this boost implementation correct? Also if anyone has other aspects, I'm open. Regards... typedef boost::shared_mutex ReadWriteMutex; typedef boost::shared_lockboost::shared_mutex ReadLock; typedef boost::unique_lockboost::shared_mutex WriteLock; class MtClass { public: MtClass() : m_value() { } ~MtClass(){} void setValue(int value) { WriteLock w_lock(rw_mutex); m_value = value; } int getValue(void) const { ReadLock r_lock(rw_mutex); return m_value; } private: int m_value; mutable ReadWriteMutex rw_mutex; };

"Selçuk Giray Özdamar"
Hi everyone,Below you can see my simple thread safe class which allows multiple readers and exclusive write for single writer. Is this boost implementation correct?
It looks fine to me. Anthony -- Anthony Williams | Just Software Solutions Ltd Custom Software Development | http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL
participants (2)
-
Anthony Williams
-
Selçuk Giray Özdamar