Class BoundedTaskQueue

java.lang.Object
org.jbrew.concurrent.AbstractBlockingTaskQueue
org.jbrew.concurrent.BoundedTaskQueue
All Implemented Interfaces:
TaskQueue<Task<? extends java.lang.Object>>

public class BoundedTaskQueue
extends AbstractBlockingTaskQueue
A BoundedTaskQueue is an unordered, bounded implementation of a TaskQueue. This implementation is ThreadSafe, as it can safely handle multiple consumer and producer threads writing and/or reading from it.
Author:
nealk
  • Field Summary

    Fields inherited from class org.jbrew.concurrent.AbstractBlockingTaskQueue

    queue
  • Constructor Summary

    Constructors 
    Constructor Description
    BoundedTaskQueue​(int capacity)  
  • Method Summary

    Modifier and Type Method Description
    void enqueue​(Task<? extends java.lang.Object> task)
    Adds an element to the head of the queue.
    int getCapacity()  

    Methods inherited from class org.jbrew.concurrent.AbstractBlockingTaskQueue

    dequeue

    Methods inherited from class java.lang.Object

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

  • Method Details

    • enqueue

      public void enqueue​(Task<? extends java.lang.Object> task) throws java.lang.InterruptedException
      Description copied from interface: TaskQueue
      Adds an element to the head of the queue. When the queue is full (bounded implementations only), the calling Thread is blocked until capacity in the queue has been released.
      Parameters:
      task - - The Task which is being added to the queue.
      Throws:
      java.lang.InterruptedException - - The method hands off the responsibility of exception handling to the caller in event of an interruption in the Thread.
    • getCapacity

      public int getCapacity()
      Returns:
      the capacity of this AbstractBlockingTaskQueue.