Synchronizable

Name

Synchronizable -- Wait queue for threads

Synopsis


#include <Synchronizable.h>
         
 class Synchronizable {

  Synchronizable();

  virtual ~Synchronizable()();

  void waitFor();
  void waitFor(long timeout);
  void waitFor(long seconds, int nanoseconds);
  void notify();
  void notifyAll();
}

Description

This class implements a wait queue for threads. A thread can place itself in a wait queue and then be awakened by another thread, or by a timeout on the wait itself.

Public member functions

Synchronizable();

Creates a thread wait queue.

virtual ~Synchronizable()();

Destroys a thread wait queue.

void waitFor();

Waits for an unbounded length of time. The method completes when either the calling thread is at the head of the wait queue and another thread invokes the notify, member or another thread invokes the notifyAll member function.

void waitFor(long timeout);

Waits as above, but for at most timeout seconds. In the current implementation, it is not possible to distinguish between a wait that times out and one that completes due to notification.

void waitFor(long seconds, int nanoseconds);

Waits as above, but for seconds seconds and at least an additional nanoseconds nanoseconds, or until notification awakens the thread.

void notify();

Wakes up the thread that least recently entered one of the wait functions and has not yet timed out.

void notifyAll();

Awakens all of the threads that are currently blocked on this object.