public final class TaskQueue<E extends AsyncQueueRecord> extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
TaskQueue.MutableMaxQueueSize |
Modifier and Type | Field and Description |
---|---|
protected Queue<WriteHandler> |
writeHandlersQueue |
Modifier | Constructor and Description |
---|---|
protected |
TaskQueue(TaskQueue.MutableMaxQueueSize maxQueueSizeHolder) |
Modifier and Type | Method and Description |
---|---|
boolean |
compareAndSetCurrentElement(E expected,
E newValue) |
static <E extends AsyncQueueRecord> |
createTaskQueue(TaskQueue.MutableMaxQueueSize maxQueueSizeHolder) |
void |
doNotify() |
boolean |
forgetWritePossible(WriteHandler writeHandler) |
Queue<E> |
getQueue()
Get the queue of tasks, which will be processed asynchronously
|
boolean |
isEmpty() |
void |
notifyWritePossible(WriteHandler writeHandler) |
void |
notifyWritePossible(WriteHandler writeHandler,
int maxQueueSize) |
void |
offer(E task)
Add the new task into the task queue.
|
void |
onClose() |
void |
onClose(Throwable cause) |
E |
peek()
Get the current processing task, if the current in not set, take the
task from the queue.
|
E |
poll()
Pools the current processing task.
|
int |
releaseSpace(int amount)
Releases memory space in the queue.
|
int |
releaseSpaceAndNotify(int amount)
Releases memory space in the queue and notifies registered
QueueMonitor s about the update. |
boolean |
remove(E task)
Remove the task from queue.
|
int |
reserveSpace(int amount)
Reserves memory space in the queue.
|
void |
setCurrentElement(E task)
Set current task element.
|
int |
size()
Returns the number of queued bytes.
|
int |
spaceInBytes()
Returns the number of queued bytes.
|
protected final Queue<WriteHandler> writeHandlersQueue
protected TaskQueue(TaskQueue.MutableMaxQueueSize maxQueueSizeHolder)
public static <E extends AsyncQueueRecord> TaskQueue<E> createTaskQueue(TaskQueue.MutableMaxQueueSize maxQueueSizeHolder)
public int size()
public E poll()
setCurrentElement(org.glassfish.grizzly.asyncqueue.AsyncQueueRecord)
without overwriting any existing queue element.public E peek()
setCurrentElement(org.glassfish.grizzly.asyncqueue.AsyncQueueRecord)
and passing null as a parameter, this is a little bit more optimal
alternative to poll()
.public int reserveSpace(int amount)
public int releaseSpace(int amount)
public int releaseSpaceAndNotify(int amount)
QueueMonitor
s about the update.public int spaceInBytes()
public Queue<E> getQueue()
public void notifyWritePossible(WriteHandler writeHandler)
public void notifyWritePossible(WriteHandler writeHandler, int maxQueueSize)
public final boolean forgetWritePossible(WriteHandler writeHandler)
public void doNotify()
public void setCurrentElement(E task)
task
- current element.public boolean remove(E task)
task
- the task to remove.public void offer(E task)
task
- new task.public boolean isEmpty()
public void onClose()
public void onClose(Throwable cause)
Copyright © 2015 Oracle Corporation. All rights reserved.