javax.realtime
Class WaitFreeDequeue

java.lang.Object
  |
  +--javax.realtime.WaitFreeDequeue

public class WaitFreeDequeue
extends java.lang.Object

The wait-free queue classes facilitate communication and synchronization between instances of RealtimeThread and Thread. See WaitFreeWriteQueue or WaitFreeReadQueue for more details. Instances of this class create a WaitFreeWriteQueue and a WaitFreeReadQueue and make calls on the respective read() and write() methods.


Constructor Summary
WaitFreeDequeue(java.lang.Thread writer, java.lang.Thread reader, int maximum, MemoryArea area)
          A queue with unsynchronized and nonblocking read() and write() methods and synchronized and blocking read()and write() methods.
 
Method Summary
 java.lang.Object blockingRead()
          A synchronized call of the read() method of the underlying WaitFreeWriteQueue.
 boolean blockingWrite(java.lang.Object object)
          A synchronized call of the write() method of the underlying WaitFreeReadQueue.
 boolean force(java.lang.Object object)
          If this is full then this call overwrites the last object written to this with the given object.
 java.lang.Object nonBlockingRead()
          An unsynchronized call of the read() method of the underlying WaitFreeReadQueue.
 boolean nonBlockingWrite(java.lang.Object object)
          An unsynchronized call of the write() method of the underlying WaitFreeWriteQueue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WaitFreeDequeue

public WaitFreeDequeue(java.lang.Thread writer,
                       java.lang.Thread reader,
                       int maximum,
                       MemoryArea area)
                throws java.lang.IllegalArgumentException,
                       java.lang.IllegalAccessException,
                       java.lang.ClassNotFoundException,
                       java.lang.InstantiationException
A queue with unsynchronized and nonblocking read() and write() methods and synchronized and blocking read()and write() methods.
Parameters:
writer - An instance of Thread.
reader - An instance of Thread.
maximum - Then maximum number of elements in the both the WaitFreeReadQueue and the WaitFreeWriteQueue.
area - The MemoryArea in which this object and internal elements are allocated.
Method Detail

nonBlockingRead

public java.lang.Object nonBlockingRead()
An unsynchronized call of the read() method of the underlying WaitFreeReadQueue.
Returns:
A Object object read from this. If there are no elements in this then null is returned.

blockingWrite

public boolean blockingWrite(java.lang.Object object)
                      throws MemoryScopeException
A synchronized call of the write() method of the underlying WaitFreeReadQueue. This call blocks on queue full and waits until there is space in this.
Parameters:
object - The Object to place in this.
Returns:
True if object is now in this.

nonBlockingWrite

public boolean nonBlockingWrite(java.lang.Object object)
                         throws MemoryScopeException
An unsynchronized call of the write() method of the underlying WaitFreeWriteQueue. This call does not block on queue full.
Parameters:
object - The Object to attempt to place in this.
Returns:
True if the object is now in this, otherwise returns false.

blockingRead

public java.lang.Object blockingRead()
A synchronized call of the read() method of the underlying WaitFreeWriteQueue. This call blocks on queue empty and will wait until there is an element in the queue to return.
Returns:
An Object from this.

force

public boolean force(java.lang.Object object)
If this is full then this call overwrites the last object written to this with the given object. If this is not full this call is equivalent to the nonBlockingWrite() call.
Parameters:
object - The Object which will overwrite the last object if this is full. Otherwise object will be placed in this.