fltk::SignalMutex Class Reference

#include <Threads.h>

Inherits fltk::Mutex.

List of all members.

Detailed Description

A portable "semaphore". A thread that holds this lock() can call wait(), which will unlock it, then wait for another thread to call signal(), then lock() it again.

The other thread can call signal() at any time, though usually it will have called lock() as well, as the lock can be used to protect the data that is actually being shared between the threads.

If more than one thread is in wait(), then calling signal_one() will only wake one of them up. This may be more efficient, and can be done safely if all threads that call wait() also call signal_one() just before calling unlock().

Warning: wait() can return even if signal() was not called. You must then check other data (protected by the lock()) to see if the condition really is fulfilled. In many cases this is the best implementation, it is also necessary to work around design errors in Windows, where always returns after 1/2 second to avoid a deadlock due to the non-atomic nature of Windows calls.

The documentation for this class was generated from the following file: