Suppose I have a class with the following interface:
class IEvent
{
void SetEvent() = 0;
void WaitForEvent() = 0;
}
WaitForEvent()
is a blocking function which waits until another thread calls SetEvent()
function.
I'm writing unit tests for this class and want following scenario:
First thread calls WaitForEvent()
. After that second thread calls SetEvent()
.
How to synchronize this threads that SetEvent()
call will always follow WaitForEvent()
call?
I don't want to use any sleeps because I want unit tests to run as fast as possible.
Aucun commentaire:
Enregistrer un commentaire