Package org.jbrew.concurrent
Class TaskRegister
java.lang.Object
org.jbrew.concurrent.TaskRegister
- All Implemented Interfaces:
TaskRegistry
public class TaskRegister extends java.lang.Object implements TaskRegistry
-
Constructor Summary
Constructors Constructor Description TaskRegister()
-
Method Summary
Modifier and Type Method Description int
getRegistrySize()
Returns the size of theTaskRegistry
, represented as a signed 8, 16, or 32 bit integer.void
interruptAll()
interuptAll() implementation is the subject of (#79), and as such MAY be addressed prior to release of v0.1.0.void
offer(Task<?> task)
Inserts the specified element into thisTaskRegistry
.void
offer(Task<?>... tasks)
Inserts the specified element into thisTaskRegistry
.Task<?>
pollTask()
boolean
remove(Task<?> task)
Removes a single instance of the specifiedTask
from thisTaskRegistry
, if it is present.
-
Constructor Details
-
TaskRegister
public TaskRegister()
-
-
Method Details
-
offer
Description copied from interface:TaskRegistry
Inserts the specified element into thisTaskRegistry
. On average, the performance runtime of this method is O(1).- Specified by:
offer
in interfaceTaskRegistry
- Parameters:
task
- - TheTask
to be inserted.- See Also:
offer(Task)
-
offer
Inserts the specified element into thisTaskRegistry
. This is thevarargs
implementation ofTaskRegistry.offer(Task)
, meaning that it handles all instances where there are either 0 or >1 parameter arguments present.
This implementation also prevents a non-initializedTask
from entering theTaskRegistry
. The reason for this inclusion is to prevent a nullTask
from consuming computing resources, including worker threads and memory. Note that this scan and check may spawn 0 or more worker threads to achieve efficient, high-performance checking. As a result of this scan, one can expect an asymptotic runtime upper bounding (worse-case performance) of O(n), where n is the number of elements present in this method's parameter{s). For the O(1) implementation of this method, please refer tooffer(Task)
.- Specified by:
offer
in interfaceTaskRegistry
- Parameters:
tasks
- - The set of zero or moreTask
to be inserted into this registry.
-
remove
Description copied from interface:TaskRegistry
Removes a single instance of the specifiedTask
from thisTaskRegistry
, if it is present. More formally, removes aTask task
such thattask
is no longer present in theTaskRegistry
if thisTaskRegistry
contains one or more such elements.- Specified by:
remove
in interfaceTaskRegistry
- Parameters:
task
- - TheTask
to be removed.- Returns:
-
pollTask
- Specified by:
pollTask
in interfaceTaskRegistry
-
interruptAll
public void interruptAll()interuptAll() implementation is the subject of (#79), and as such MAY be addressed prior to release of v0.1.0.- Specified by:
interruptAll
in interfaceTaskRegistry
-
getRegistrySize
public int getRegistrySize()Returns the size of theTaskRegistry
, represented as a signed 8, 16, or 32 bit integer. The value will be an 8-bit integer for sizes of less than and including 255. For values greater than 255 but less than 32,767 this will be 16 bits. Finally, for values greater than 32,767 up to the maximum integer , the value will contain 32 bits.- Specified by:
getRegistrySize
in interfaceTaskRegistry
-