public class WaitFreeWriteQueue extends Object
Jamaica Real-Time Specification for Java class WaitFreeWriteQueue.
This class permits a thread to write to one or more other threads without being blocked by the other threads. This is required in RTSJ implementations that do not have real-time garbage collection to permit communication between NoHeapRealtimeThreads and normal Threads or RealtimeThreads to avoid the potential priority inversion problem of the NoHeapRealtimeThread being blocked waiting for another thread that itself if blocked by garbage collection activity.
In the JamaicaVM implementation, a thread that does not perform memory allocation is never blocked by the garbage collector unless it was preempted by a higher priority thread that performs memory allocation. In conjunction with the priority inversion avoidance mechanisms provided for monitors in the RTSJ (priority inheritance and priority ceiling emulation), this priority-inversion situation cannot occur in JamaicaVM, and normal protection using monitors is sufficient for the communication between NoHeapRealtimeThreads and normal Java threads. This class is consequently provided only for compatibility with other RTSJ implementations that do not provide realtime garbage collection.
Constructor and Description |
---|
WaitFreeWriteQueue(int maximum)
Constructor to construct a non-blocking write queue in immortal
memory.
|
WaitFreeWriteQueue(int maximum,
MemoryArea memory)
Constructor to construct a non-blocking write queue in given
memory area.
|
WaitFreeWriteQueue(Runnable writer,
Runnable reader,
int maximum,
MemoryArea memory)
Constructor to construct a non-blocking write queue in given
memory area.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
clear clears this queue.
|
boolean |
force(Object object)
force writes object into the queue even if the queue is full.
|
boolean |
isEmpty()
isEmpty checks if the queue is currently empty.
|
boolean |
isFull()
isFull checks if the queue is currently full.
|
Object |
read()
read reads one element from the queue.
|
int |
size()
size returns the current size of the queue, i.e., the number of
elements that have been written but not yet read.
|
boolean |
write(Object object)
write writes an element to the queue.
|
public WaitFreeWriteQueue(int maximum) throws IllegalArgumentException
IllegalArgumentException
- if maximum <= 0.maximum
- capacity of this queuepublic WaitFreeWriteQueue(int maximum, MemoryArea memory) throws IllegalArgumentException
IllegalArgumentException
- if maximum <= 0 or memory is null.maximum
- capacity of this queuememory
- The memory area in which internal elements are
allocated.public WaitFreeWriteQueue(Runnable writer, Runnable reader, int maximum, MemoryArea memory) throws IllegalArgumentException, MemoryScopeException
IllegalArgumentException
- if maximum <= 0 or writer or
read are not referring to a Thread or a Schedulable object.MemoryScopeException
- if writer or reads is non-null and
in a memory area that is not assignment compatible with memory.writer
- A thread or schedulable object that may write to
this queue or nullreader
- A thread or schedulable object that may read from
this queue or null.maximum
- capacity of this queuememory
- The memory area in which internal elements are
allocated, or null.public void clear()
public boolean isEmpty()
public boolean isFull()
public Object read() throws InterruptedException
InterruptedException
- if the wait is interrupted.public int size()
public boolean force(Object object) throws MemoryScopeException
MemoryScopeException
object
- The object to be put in the queue.public boolean write(Object object)
object
- The object to be put in the queue.aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2016 aicas GmbH. All Rights Reserved.