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:
joss17 2010-04-08 19:08:20 +00:00
parent 5974ac004e
commit ffdd38ddd5
2 changed files with 54 additions and 7 deletions

View file

@ -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