@Deprecated
public class WaitFreeDequeue
extends java.lang.Object
WaitFreeDequeue
encapsulates a
WaitFreeWriteQueue
and a WaitFreeReadQueue
.
Each method on a WaitFreeDequeue
corresponds to an
equivalent operation on the underlying
WaitFreeWriteQueue
or WaitFreeReadQueue
.
Incompatibility with V1.0:
Three exceptions previously thrown by the constructor have been deleted from
the throws
clause. These are
java.lang.IllegalAccessException
,
java.lang.ClassNotFoundException
, and
java.lang.InstantiationException
.
Including these exceptions on the throws
clause was
an error. Their deletion may cause compile-time errors in code using
the previous constructor. The repair is to remove the exceptions
from the catch
clause around the constructor invocation.
WaitFreeDequeue
is one of the classes allowing
NoHeapRealtimeThread
s and regular Java threads to
synchronize on an object without the risk of a
NoHeapRealtimeThread
incurring Garbage Collector latency
due to priority inversion avoidance management.
Constructor and Description |
---|
WaitFreeDequeue(java.lang.Runnable writer,
java.lang.Runnable reader,
int maximum,
MemoryArea memory)
Deprecated.
Constructs a queue, in
memory , with an underlying
WaitFreeWriteQueue and WaitFreeReadQueue , each of
size maximum . |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
blockingRead()
Deprecated.
A synchronized call of the
read() method of the
underlying WaitFreeWriteQueue . |
void |
blockingWrite(java.lang.Object object)
Deprecated.
A synchronized call of the
write() method of the
underlying WaitFreeReadQueue . |
boolean |
force(java.lang.Object object)
Deprecated.
When
this 's underlying WaitFreeWriteQueue is
full, then overwrite with object the most recently
inserted element. |
java.lang.Object |
nonBlockingRead()
Deprecated.
An unsynchronized call of the
read()
method of the underlying WaitFreeReadQueue . |
boolean |
nonBlockingWrite(java.lang.Object object)
Deprecated.
An unsynchronized call of the
write() method of the
underlying WaitFreeWriteQueue . |
public WaitFreeDequeue(java.lang.Runnable writer, java.lang.Runnable reader, int maximum, MemoryArea memory)
memory
, with an underlying
WaitFreeWriteQueue
and WaitFreeReadQueue
, each of
size maximum
.
The writer
and reader
parameters, when
non-null, are checked to insure that they are compatible with the
MemoryArea
specified by memory
(when
non-null.) When memory
is null
and both
Runnables are non-null, the constructor will select the nearest
common scoped parent memory area, or when there is no such scope it
will use immortal memory. When all three parameters are
null
, the queue will be allocated in immortal memory.
reader
and writer
are not necessarily
the only threads or schedulables that will access the queue;
moreover, there is no check that they actually access the queue at
all.
Note that the wait free queues' internal queues are
allocated in memory
, but the memory area of the wait
free dequeue instance itself is determined by the current
allocation context.
writer
- An instance of Runnable
or null
.reader
- An instance of Runnable
or null
.maximum
- Then maximum number of elements in the both the
WaitFreeReadQueue
and the WaitFreeWriteQueue
.memory
- The MemoryArea
in which internal elements are
allocated.MemoryScopeException
- when
either reader
or writer
is non-null and the memory
argument is not
compatible with reader
and
writer
with respect to the assignment
and access rules for memory areas.java.lang.IllegalArgumentException
- When an argument holds an invalid
value. The writer
argument must be
null
, a reference to a Thread
,
or a reference to a schedulable (a
RealtimeThread
, or an
AsyncEventHandler
.) The reader
argument must be null
, a reference to a
Thread
, or a reference to a schedulable
object. The maximum
argument must be greater
than zero.InaccessibleAreaException
- when memory
is a
scoped memory that is not on the caller's scope
stack.public java.lang.Object nonBlockingRead()
read()
method of the underlying WaitFreeReadQueue
.java.lang.Object
object read from this
.
When there are no elements
in this
then null
is returned.public void blockingWrite(java.lang.Object object) throws java.lang.InterruptedException
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
- when a memory access error
or illegal assignment error would occur
while storing object
in the queue.java.lang.InterruptedException
- when the thread is interrupted by
interrupt()
or
AsynchronouslyInterruptedException.fire()
during
the time between calling this method and returning from it.true
, and
added InterruptedException.public boolean nonBlockingWrite(java.lang.Object object)
write()
method of the
underlying WaitFreeWriteQueue
.
This call does not block on queue full.object
- The Object
to attempt to place in
this
.true
when object
was inserted
(i.e., the queue was not full), false
otherwise.MemoryScopeException
- when a memory access error
or illegal assignment error would occur
while storing object
in the queue.public java.lang.Object blockingRead() throws java.lang.InterruptedException
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.java.lang.InterruptedException
- when the thread is interrupted by
interrupt()
or AsynchronouslyInterruptedException.fire()
during the time
between calling this method and returning from it.InterruptedException
.public boolean force(java.lang.Object object)
this
's underlying WaitFreeWriteQueue
is
full, then overwrite with object
the most recently
inserted element. Otherwise this call is equivalent to
nonBlockingWrite()
.object
- The object to be written.true
when an element was overwritten;
false
when there as an empty element
into which the write occurred.MemoryScopeException
- when a memory access error
or illegal assignment error would occur
while storing object
in the queue.