jarol
Class Signal

java.lang.Object
  extended by jarol.Signal

public class Signal
extends java.lang.Object

Signal is a synchronization point, the await() call causes the callers (e.g., thread, process, exotask,...) to be suspended until a signal() call is performed by an arbitary task.

A SignalException is thrown in the following cases:
(1) signal() is invoked and there is no thread awaiting. - SignalNotAwaitedException
(2) signal() is invoked while signaling is in progress (during the wake up phase of awaiting threads). - SignalDuringSignalingException
(3) await() is invoked while signaling is in progress. - AwaitDuringSignalingException
(4) the awaiting thread is interrupted (interrupt() called).

Version:
0.1
Author:
Bernhard Kast

Constructor Summary
Signal()
          Constructs a signal.
Signal(java.lang.String name, boolean debug)
          Creates a signal with a specified name and the debug flag.
 
Method Summary
 void await()
          Causes the caller to be suspended until signal() is called.
 void signal()
          All callers of await() tasks are resumed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Signal

public Signal()
Constructs a signal.


Signal

public Signal(java.lang.String name,
              boolean debug)
Creates a signal with a specified name and the debug flag. This allows the developer to watch the signaling sequence on the standard input/output.
The outputs are as follows:
for a signal() ("SIGNAL " + name)
for a await() ("AWAIT " + name)
for a received signal() after an await() ("AWAIT " + name + " leaving!")

Parameters:
name - - The name of the Clock.
Method Detail

signal

public void signal()
            throws SignalDuringSignalingException,
                   SignalNotAwaitedException
All callers of await() tasks are resumed. A SignalException is thrown, if a signal is invoked without a caller awaiting or signal occured while signaling is in progress.

Throws:
SignalDuringSignalingException
SignalNotAwaitedException

await

public void await()
           throws AwaitDuringSignalingException
Causes the caller to be suspended until signal() is called. A SignalException is thrown, if an await() is invoked without while signaling is in progress or a InterruptedException is caught.

Throws:
AwaitDuringSignalingException