mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-05 21:29:23 -04:00
add the internal counter mutex lock. Move the code of the rw mutec to the rsthreads.cc file
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2697 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
5974ac004e
commit
ffdd38ddd5
2 changed files with 54 additions and 7 deletions
|
@ -101,15 +101,15 @@ class RsStackMutex
|
|||
class RsReadWriteMutex: public RsMutex
|
||||
{
|
||||
public:
|
||||
RsReadWriteMutex(): readLocks(0) { }
|
||||
RsReadWriteMutex();
|
||||
|
||||
void readLock() { if (readLocks == 0) {lock();} ; readLocks++;}
|
||||
void readUnlock() { if (readLocks == 1) {unlock();} if (readLocks != 0) {readLocks--;} }
|
||||
void writeLock() {lock();}
|
||||
void writeUnlock() {unlock();}
|
||||
void readLock();
|
||||
void readUnlock();
|
||||
void writeLock();
|
||||
void writeUnlock();
|
||||
|
||||
void rwlock(uint32_t type) { if (type & READ_LOCK) {readLock();} else {writeLock();} }
|
||||
void rwunlock(uint32_t type) { if (type & READ_LOCK) {readUnlock();} else {writeUnlock();} }
|
||||
void rwlock(uint32_t type);
|
||||
void rwunlock(uint32_t type);
|
||||
|
||||
const static uint32_t READ_LOCK = 0x0001;
|
||||
const static uint32_t WRITE_LOCK = 0x0002;
|
||||
|
@ -117,6 +117,7 @@ class RsReadWriteMutex: public RsMutex
|
|||
|
||||
private:
|
||||
int readLocks;
|
||||
RsMutex internalCounterMtx;
|
||||
};
|
||||
|
||||
class RsStackReadWriteMutex
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue