Reindroduce the read/write mutex for AuthGPG as mutex for the data member.

Added second mutex for the gpg engine.
Now the call to the gpg engine (for example AuthGPGimpl::LoadCertificateFromString) doesn't block the GUI.
The existing problem is still the call of AuthGPGimpl::storeAllKeys every minute before access the gpg data.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3555 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-09-28 22:30:57 +00:00
parent 0e460eec90
commit d3fc7f3982
4 changed files with 238 additions and 166 deletions

View file

@ -102,41 +102,40 @@ class RsStackMutex
RsMutex &mMtx;
};
// maybe we can use it again
//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 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;