public class ObjectQueue
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private class |
ObjectQueue.QueueItem
Simple LinkedList-like list item used in the
ObjectQueue class. |
Modifier and Type | Field and Description |
---|---|
private boolean |
m_bClosed
Signals if the
take() method should stop blocking. |
private ObjectQueue.QueueItem |
m_foot
Least recently added object.
|
private ObjectQueue.QueueItem |
m_head
Most recently added object.
|
private int |
m_size
Number of objects currently in the queue.
|
Constructor and Description |
---|
ObjectQueue() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Signals the closing of this queue, interrupting any running
take() method calls. |
int |
getSize()
Returns the number of objects currently in the queue.
|
boolean |
isEmpty() |
java.lang.Object |
poll(int a_msTimeout)
Tries returning an object using
pop() . |
java.lang.Object |
pop()
Returns the least recent object in the queue.
|
void |
push(java.lang.Object a_object)
Pushes an object to the head of the queue.
|
java.lang.Object |
take()
If the queue is empty this method blocks until a new item is available
or the queue has been closed using
close() . |
private ObjectQueue.QueueItem m_head
private ObjectQueue.QueueItem m_foot
private int m_size
private volatile boolean m_bClosed
take()
method should stop blocking.public int getSize()
public void close()
take()
method calls.
Note: This doesn't affect any other method calls and gets undone, when pushing an object into the queue.
public void push(java.lang.Object a_object)
a_object
- public java.lang.Object pop()
public java.lang.Object take()
close()
.public java.lang.Object poll(int a_msTimeout) throws java.lang.InterruptedException
pop()
. If no object was
available it waits a_msTimeout
milliseconds and calls
pop()
, returning the result.a_msTimeout
- Amount of milliseconds to wait, if queue is empty.pop()
. null, if null was returned.java.lang.InterruptedException
public boolean isEmpty()
Copyright © 2023. All rights reserved.