|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.realtime.WaitFreeWriteQueue
The wait-free queue classes facilitate communication and synchronization
between instances of RealtimeThread
and Thread
.
The problem is that synchronized access
objects shared between real-time threads and threads might cause the real-time threads to
incur delays due to execution of the garbage collector.
The write
method of
this class does not block on an imagined queue-full condition variable. If the
write()
method is called on a full queue false is returned. If two
real-time threads intend to read from this queue they must provide their own
synchronization.
The read()
method of this queue is synchronized and may be
called by more than one writer and will block on queue empty.
Constructor Summary | |
WaitFreeWriteQueue(java.lang.Thread writer,
java.lang.Thread reader,
int maximum,
MemoryArea memory)
A queue with an unsynchronized and nonblocking write() method and a
synchronized and blocking read() method. |
Method Summary | |
void |
clear()
Set this to empty. |
boolean |
force(java.lang.Object object)
Force this Object to replace the last one. |
boolean |
isEmpty()
Used to determine if this is empty. |
boolean |
isFull()
Used to determine if this is full. |
java.lang.Object |
read()
A synchronized read on the queue. |
int |
size()
Used to determine the number of elements in this. |
boolean |
write(java.lang.Object object)
Try to insert an element into the queue. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public WaitFreeWriteQueue(java.lang.Thread writer, java.lang.Thread reader, int maximum, MemoryArea memory) throws java.lang.IllegalArgumentException, java.lang.InstantiationException, java.lang.ClassNotFoundException, java.lang.IllegalAccessException
write()
method and a
synchronized and blocking read()
method.writer
- An instance of Thread
.reader
- An instance of Thread
.maximum
- The maximum number of elements in the queue.memory
- The MemoryArea
in which this object and internal elements are
allocated.Method Detail |
public void clear()
public boolean isEmpty()
public boolean isFull()
public java.lang.Object read()
Object
read or null if this is empty.public int size()
public boolean force(java.lang.Object object) throws MemoryScopeException
Object
to replace the last one.
If the reader should happen to have just removed the other Object
just as we were
updating it, we will return false. False may mean that it just saw what we put in there.
Either way, the best thing to do is to just
write again -- which will succeed, and check on the readers side for consecutive identical
read values.object
was enqueued,
and the last entry was overwritten with object
public boolean write(java.lang.Object object) throws MemoryScopeException
object
- The Object
to insert.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |