Class JobQueue

java.lang.Object
net.officefloor.frame.impl.spi.team.JobQueue

public class JobQueue extends Object
Queue of Job instances.
Author:
Daniel Sagenschneider
  • Constructor Details

    • JobQueue

      public JobQueue()
      Initiate with private lock.
    • JobQueue

      public JobQueue(Object lock)
      Initiate.
      Parameters:
      lock - Lock for coordinating this JobQueue.
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Indicates if no Job instances within the queue.
      Returns:
      No Job instances within the queue.
    • enqueue

      public void enqueue(Job job)
      Thread-safe enqueues a Job to the queue.
      Parameters:
      job - Job to add to the queue.
    • dequeue

      public Job dequeue()
      Thread-safe dequeuing the next Job to execute.
      Returns:
      Next Job to execute or null if no Job currently available.
    • dequeue

      public Job dequeue(long timeout)
      Thread-safe dequeuing the next Job to execute. This will block for timeout milliseconds for a Job to become available.
      Parameters:
      timeout - Timeout to wait for dequeuing a Job.
      Returns:
      Next Job to execute or null if timed out waiting for next Job.
    • wakeUp

      public void wakeUp()
      Wakes up waiting on a Job.
    • waitForTask

      public void waitForTask(long timeout)
      Waits the input period of time for another Job to be added.
      Parameters:
      timeout - Time to wait in milliseconds.