|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.realtime.WaitFreeReadQueue
The wait-free queue class 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 read()
method of this class does not block on an
imagined queue-empty condition variable. If the read()
is called on an empty queue null is returned. If two real-time
threads intend to read from this queue they must provide their
own synchronization.
The write()
method of this queue is synchronized and
may be called by more than one writer and will block on queue empty.
Field Summary | |
protected int |
currentIndex
|
protected javax.realtime.MemoryArea |
memArea
|
protected boolean |
notify
|
protected int |
queueSize
|
protected java.lang.Thread |
readerThread
|
protected java.lang.Object[] |
readQueue
|
protected java.lang.Thread |
writerThread
|
Constructor Summary | |
WaitFreeReadQueue(java.lang.Thread writer,
java.lang.Thread reader,
int maximum,
javax.realtime.MemoryArea memory)
A queue with an unsynchronizes and nonblocking read()
method and a synchronized and blocking write() method. |
|
WaitFreeReadQueue(java.lang.Thread writer,
java.lang.Thread reader,
int maximum,
javax.realtime.MemoryArea memory,
boolean notify)
A queue with an unsynchronizes and nonblocking read()
method and a synchronized and blocking write() method. |
Method Summary | |
void |
clear()
Set this to empty. |
boolean |
isEmpty()
Queries the system to determine if this is empty. |
boolean |
isFull()
Queries the system to determine if this is full. |
java.lang.Object |
read()
Reads the next element in the queue unless the queue is empty. |
int |
size()
Queries the system to determine the number of elements in this . |
void |
waitForData()
If this is empty waitForData() waits on
the event until the writer inserts data. |
boolean |
write(java.lang.Object object)
The synchronized and blocking write. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected boolean notify
protected java.lang.Object[] readQueue
protected int queueSize
protected int currentIndex
protected java.lang.Thread writerThread
protected java.lang.Thread readerThread
protected javax.realtime.MemoryArea memArea
Constructor Detail |
public WaitFreeReadQueue(java.lang.Thread writer, java.lang.Thread reader, int maximum, javax.realtime.MemoryArea memory) throws java.lang.IllegalArgumentException
read()
method and a synchronized and blocking write()
method.
writer
- An instance of java.lang.Thread
.reader
- An instance of java.lang.Thread
.maximum
- The maximum number of elements in the queue.memory
- The MemoryArea
in which this object and
internal elements are alocated.
java.lang.IllegalArgumentException
public WaitFreeReadQueue(java.lang.Thread writer, java.lang.Thread reader, int maximum, javax.realtime.MemoryArea memory, boolean notify) throws java.lang.IllegalArgumentException
read()
method and a synchronized and blocking write()
method.
writer
- An instance of java.lang.Thread
.reader
- An instance of java.lang.Thread
.maximum
- The maximum number of elements in the queue.memory
- The MemoryArea
in which this object and
internal elements are alocated.notify
- Whether or not the reader is notified when data is added.
java.lang.IllegalArgumentException
Method Detail |
public void clear()
this
to empty.
public boolean isEmpty()
this
is empty.
this
is empty. False, if
this
is not empty.public boolean isFull()
this
is full.
this
is full. False, if
this
is not full.public java.lang.Object read()
java.lang.Object
read.
Null, if this
was empty.public int size()
this
.
this
.public void waitForData()
this
is empty waitForData()
waits on
the event until the writer inserts data. Note that true priority
inversion does not occur since the writer locks a different object
and the notify is executed by the AsyncEventHandler
which has noHeap
characteristics.
public boolean write(java.lang.Object object) throws MemoryScopeException
object
- The java.lang.Object
that is placed in
this
.
MemoryScopeException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |