public class SchedulerQueue extends Object
This class is responsible for managing a queue of scheduler commands. This functionality is needed by the asynchronous protocol mode and the Scheduler class. New commands can be added with the enqueue method. Commands can be dequeued with dequeue. This queue does not have a maximum size or count.
This class is not guaranteed to be thread-safe.
| Modifier and Type | Class and Description |
|---|---|
static class |
SchedulerQueue.QueueEnd |
| Constructor and Description |
|---|
SchedulerQueue() |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all scheduler commands from this queue.
|
SchedulerCommand |
dequeue()
Returns a scheduler command and removes it from the queue.
|
void |
enqueue(SchedulerCommand command,
SchedulerQueue.QueueEnd insertTo)
Adds a new scheduler command to the queue.
|
int |
getCount()
Returns the current amount of scheduler commands in this queue.
|
long |
getSize()
Returns the current size of this queue in bytes.
|
boolean |
trim(int size)
Tries to skip and remove scheduler commands from this queue.
|
public static final Logger logger
public void enqueue(SchedulerCommand command, SchedulerQueue.QueueEnd insertTo)
This method adds the supplied scheduler command to the queue. The size of the queue is incremented by the size of the supplied command (plus some internal management overhead). This queue does not have a maximum size or count.
command - The command to addinsertTo - The queue end to insert the command to (head or tail)public SchedulerCommand dequeue()
public boolean trim(int size)
size - The minimum amount of bytes to remove from this queuepublic void clear()
Removing all scheduler commands of the queue is done by calling the dequeue method for each command in the current queue
public int getCount()
For each added scheduler command this counter is incremented by one and for each removed command (with dequeue) this counter is decremented by one. If the queue is empty, this method returns 0.
public long getSize()
For each added scheduler command this counter is incremented by the size of the command (plus some internal management overhead) and for each removed command (with dequeue) this counter is then decremented again. If the queue is empty, this method returns 0.
Copyright © 2023. All rights reserved.