|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.realtime.WaitFreeDequeue
The wait-free classes facilitate communication and synchronization
between instances of RealtimeThread
and Thread
.
Field Summary | |
protected int |
currentIndex
|
protected javax.realtime.MemoryArea |
memArea
|
protected java.lang.Object[] |
queue
|
protected int |
queueSize
|
protected java.lang.Thread |
readerThread
|
protected java.lang.Thread |
writerThread
|
Constructor Summary | |
WaitFreeDequeue(java.lang.Thread writer,
java.lang.Thread reader,
int maximum,
javax.realtime.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. |
private boolean |
isEmpty()
Used to check if the queue is empty. |
private boolean |
isFull()
Used to check if the queue is full. |
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 |
Field Detail |
protected java.lang.Object[] queue
protected int queueSize
protected int currentIndex
protected java.lang.Thread writerThread
protected java.lang.Thread readerThread
protected javax.realtime.MemoryArea memArea
Constructor Detail |
public WaitFreeDequeue(java.lang.Thread writer, java.lang.Thread reader, int maximum, javax.realtime.MemoryArea area) throws java.lang.IllegalArgumentException
read()
and write()
methods and synchronized and blocking
read()
and write()
methods.
writer
- An instance of Thread
.reader
- An instance of Thread
.maximum
- The maximum number of elements in both the
WaitFreeReadQueue
and the
WaitFreeWriteQueue
.area
- The MemoryArea
in which this object and
internal elements are allocated
java.lang.IllegalArgumentException
- If an argument holds an
invalid value. The current
memory areas of
writer
,
reader
, and
memory
must be
compatible with respect to
the assignment and access
rules for memory areas.Method Detail |
private boolean isEmpty()
private boolean isFull()
public java.lang.Object blockingRead()
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.
java.lang.Object
read.public boolean blockingWrite(java.lang.Object object) throws MemoryScopeException
write()
method of the
underlying WaitFreeReadQueue
. This call blocks on
queue full and waits until there is space in this
.
object
- The java.lang.Object
to place in
this
.
MemoryScopeException
- If the write causes an access or
assignment violation.public boolean force(java.lang.Object object)
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.
object
- The java.lang.Object which will overwrite
the last object if this
is full.
Otherwise object
will be placed in
thisReturns:- True, if an element was overwritten. False, if there
is an empty element into which the write occured.
public java.lang.Object nonBlockingRead()
read()
method of the
underlying WaitFreeReadQueue
.
java.lang.Object
object read from
this
. If there are no elements in
this
then null is returned.public boolean nonBlockingWrite(java.lang.Object object) throws MemoryScopeException
write()
method of the
underlying WaitFreeWriteQueue
. This call does not
block on queue full.
object
- The java.lang.Object
to attempt to
place in this
.
this
, otherwise
returns false.
MemoryScopeException
- If the write causes an access or
assignment violation.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |