gov.nasa.gsfc.drl.rtstps.clients.spooler
Class Signal

java.lang.Object
  extended by gov.nasa.gsfc.drl.rtstps.clients.spooler.Signal

final class Signal
extends java.lang.Object

This class is a monitor object. Its primary use is for the socket reader to awaken the socket writer. It has a secondary use. The socket writer tells the socket reader that it has terminated.

Note that the implementation uses two unlocking mechanisms. The counters are used when the reader is not yet waiting to receive. It prevents a deadlock.


Field Summary
private  int receiveCount
           
private  int sendCount
           
private  boolean socketWriterTerminated
           
 
Constructor Summary
Signal()
           
 
Method Summary
(package private)  boolean isTerminated()
          Has the socket writer terminated?
(package private)  void receive()
          The socket writer tests for a signal and waits if there is none.
(package private)  void send()
          The socket reader signals the socket writer that data is available.
(package private)  void terminate()
          The socket writer signals that it is no longer sending data to the output socket.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sendCount

private volatile int sendCount

receiveCount

private volatile int receiveCount

socketWriterTerminated

private boolean socketWriterTerminated
Constructor Detail

Signal

Signal()
Method Detail

send

void send()
The socket reader signals the socket writer that data is available. It awakens the socket writer.


receive

void receive()
       throws java.lang.InterruptedException
The socket writer tests for a signal and waits if there is none.

Throws:
java.lang.InterruptedException

terminate

final void terminate()
The socket writer signals that it is no longer sending data to the output socket.


isTerminated

final boolean isTerminated()
Has the socket writer terminated?