mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -04:00
Removed read/write mutex from AuthGPGimpl and from the sources.
Added RsThread as base class to AuthGPGimpl and load all gpg keys every hour. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3571 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
bb4aedf55f
commit
acf57ed3fd
5 changed files with 72 additions and 137 deletions
|
@ -156,50 +156,3 @@ void RsQueueThread::run()
|
|||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
RsReadWriteMutex::RsReadWriteMutex():readLocks(0) {
|
||||
}
|
||||
|
||||
void RsReadWriteMutex::readLock() {
|
||||
internalCounterMtx.lock();//lock internal read counter
|
||||
if (readLocks == 0) {
|
||||
lock(); //lock normal mutex
|
||||
}
|
||||
readLocks++;
|
||||
internalCounterMtx.unlock();
|
||||
}
|
||||
|
||||
void RsReadWriteMutex::readUnlock() {
|
||||
internalCounterMtx.lock();//lock internal read counter
|
||||
if (readLocks == 1) {
|
||||
unlock();
|
||||
}
|
||||
if (readLocks != 0) {
|
||||
readLocks--;
|
||||
}
|
||||
internalCounterMtx.unlock();
|
||||
}
|
||||
|
||||
void RsReadWriteMutex::writeLock() {
|
||||
lock();
|
||||
}
|
||||
|
||||
void RsReadWriteMutex::writeUnlock() {
|
||||
unlock();
|
||||
}
|
||||
|
||||
void RsReadWriteMutex::rwlock(uint32_t type) {
|
||||
if (type & READ_LOCK) {
|
||||
readLock();
|
||||
} else {
|
||||
writeLock();
|
||||
}
|
||||
}
|
||||
|
||||
void RsReadWriteMutex::rwunlock(uint32_t type) {
|
||||
if (type & READ_LOCK) {
|
||||
readUnlock();
|
||||
} else {
|
||||
writeUnlock();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,41 +102,6 @@ class RsStackMutex
|
|||
RsMutex &mMtx;
|
||||
};
|
||||
|
||||
class RsReadWriteMutex: public RsMutex
|
||||
{
|
||||
public:
|
||||
RsReadWriteMutex();
|
||||
|
||||
void readLock();
|
||||
void readUnlock();
|
||||
void writeLock();
|
||||
void 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;
|
||||
|
||||
|
||||
private:
|
||||
int readLocks;
|
||||
RsMutex internalCounterMtx;
|
||||
};
|
||||
|
||||
class RsStackReadWriteMutex
|
||||
{
|
||||
public:
|
||||
|
||||
RsStackReadWriteMutex(RsReadWriteMutex &mtx): mMtx(mtx) { mMtx.writeLock(); writeLock = true;}
|
||||
RsStackReadWriteMutex(RsReadWriteMutex &mtx, uint32_t type): mMtx(mtx) { if (type == RsReadWriteMutex::READ_LOCK) {mMtx.readLock(); writeLock = false;} else {mMtx.writeLock(); writeLock = true;} }
|
||||
~RsStackReadWriteMutex() { if(writeLock) {mMtx.writeUnlock();} else {mMtx.readUnlock();} }
|
||||
|
||||
private:
|
||||
RsReadWriteMutex &mMtx;
|
||||
bool writeLock;
|
||||
};
|
||||
|
||||
class RsThread;
|
||||
|
||||
/* to create a thread! */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue