Interface ProducerConsumer<T>

All Known Subinterfaces:
ProducerConsumer.MultiConsumer<T>, ProducerConsumer.MultiProducer<T>, ProducerConsumer.MultiProducerConsumer<T>, ProducerConsumer.SingleProducerConsumer<T>
All Known Implementing Classes:
LockFreeArrayQueue, ProducerConsumerWithTake

public interface ProducerConsumer<T>
Basis for LIFO, FIFO, Pool, and variants
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Must implement at least: Multiple threads may call consume(), one thread may call produce()
    static interface 
    Must implement at least: Multiple threads may call produce(), one thread may call consume()
    static interface 
    Must implement at least: Multiple threads may call produce(), multiple threads may call consume()
    static interface 
    Must implement at least: One thread may call produce(), one thread may call consume()
  • Method Summary

    Modifier and Type
    Method
    Description
    This method should never block (but it may spin for a finite amount of time) Returns null when there is nothing to consume [may create new objects on the fly if necessary]
    boolean
    This method should never block (but it may spin for a finite amount of time) Returns true when t was successfully produced, else false
  • Method Details

    • produce

      boolean produce(T t)
      This method should never block (but it may spin for a finite amount of time) Returns true when t was successfully produced, else false
    • consume

      T consume()
      This method should never block (but it may spin for a finite amount of time) Returns null when there is nothing to consume [may create new objects on the fly if necessary]