I have a program involving three TThread objects (thread1, thread2, thread3) and two TMutex objects (mutex12, mutex23). I would like to make thread1 and thread2 mutually exclusive using mutex1. Also, I would like to make thread2 and thread3 mutually exclusive using mutex23. My implementation is something like:
[code]//Thread1
{
R__LOCKGUARD(mutex12);
Commands(…);
}
//Thread2
{
R__LOCKGUARD(mutex12);
R__LOCKGUARD(mutex23);
MoreCommands(…);
}
//Thread3
{
R__LOCKGUARD(mutex23);
OtherCommands(…);
}[/code]
However, this will not compile. Is there a way to implement a scenario like this?
Does TMutex::Lock() pause the thread it’s in, if the mutex is already locked? If this is the case, I know the answer to my own question, but the documentation in the class index doesn’t specify if this is the case.
Thanks!