public class WaitFreeWriteQueue<T> 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(T 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.
|
T |
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(T object)
write writes an element to the queue.
|
public WaitFreeWriteQueue(int maximum) throws StaticIllegalArgumentException
StaticIllegalArgumentException
- if maximum <= 0.maximum
- capacity of this queuepublic WaitFreeWriteQueue(int maximum, MemoryArea memory) throws StaticIllegalArgumentException
StaticIllegalArgumentException
- 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 StaticIllegalArgumentException, MemoryScopeException, InaccessibleAreaException
StaticIllegalArgumentException
- if maximum <= 0 or writer or
reader are not referring to a Thread or a Schedulable object.MemoryScopeException
- if writer or reader is non-null and
in a memory area that is not assignment compatible with memory.InaccessibleAreaException
- if memory is a scoped memory that is not
on the caller's scope stack.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 T read() throws InterruptedException
InterruptedException
- if the wait is interrupted.public int size()
public boolean force(T object) throws MemoryScopeException
StaticIllegalArgumentException
- when object is nullMemoryScopeException
object
- The object to be put in the queue.public boolean write(T object)
StaticIllegalArgumentException
- when object is nullobject
- The object to be put in the queue.aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2022 aicas GmbH. All Rights Reserved.