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 the TaskRegistry, 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 this TaskRegistry.
    void offer​(Task<?>... tasks)
    Inserts the specified element into this TaskRegistry.
    Task<?> pollTask()  
    boolean remove​(Task<?> task)
    Removes a single instance of the specified Task from this TaskRegistry, if it is present.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • offer

      public void offer​(Task<?> task)
      Description copied from interface: TaskRegistry
      Inserts the specified element into this TaskRegistry. On average, the performance runtime of this method is O(1).
      Specified by:
      offer in interface TaskRegistry
      Parameters:
      task - - The Task to be inserted.
      See Also:
      offer(Task)
    • offer

      @SafeVarargs public final void offer​(Task<?>... tasks)
      Inserts the specified element into this TaskRegistry. This is the varargs implementation of TaskRegistry.offer(Task), meaning that it handles all instances where there are either 0 or >1 parameter arguments present.

      This implementation also prevents a non-initialized Task from entering the TaskRegistry. The reason for this inclusion is to prevent a null Task 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 to offer(Task).
      Specified by:
      offer in interface TaskRegistry
      Parameters:
      tasks - - The set of zero or more Task to be inserted into this registry.
    • remove

      public boolean remove​(Task<?> task)
      Description copied from interface: TaskRegistry
      Removes a single instance of the specified Task from this TaskRegistry, if it is present. More formally, removes a Task task such that task is no longer present in the TaskRegistry if this TaskRegistry contains one or more such elements.
      Specified by:
      remove in interface TaskRegistry
      Parameters:
      task - - The Task to be removed.
      Returns:
    • pollTask

      public Task<?> pollTask()
      Specified by:
      pollTask in interface TaskRegistry
    • 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 interface TaskRegistry
    • getRegistrySize

      public int getRegistrySize()
      Returns the size of the TaskRegistry, 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 interface TaskRegistry