To apply a general lock, I can do this:
CAutoLock(CCritSec * plock)
But how can I set read and write lock respectively?
To apply a general lock, I can do this:
CAutoLock(CCritSec * plock)
But how can I set read and write lock respectively?
I would just use two separate locks...it might be possible otherwise tho.
Simply have two separate CCritSec objects:
CCritSec writeLock, readLock;
void Blah::SomeMethod()
{
CAutoLock writeAutoLock( &writeLock );
...
}
void Blah::SomeOtherMethod()
{
CAutoLock readAutoLock( &readLock );
}
You can also lock without the auto-lock class, but I wouldn't recommend it unless your functions/methods are short and there's no possible way you'd forget to unlock.