Interface ChannelQueue<T>

Type Parameters:
T - type of values stored in the queue
All Superinterfaces:
io.activej.async.process.AsyncCloseable, ChannelConsumerTransformer<T,ChannelConsumer<T>>, ChannelSupplierTransformer<T,ChannelSupplier<T>>, ChannelTransformer<T,T>
All Known Implementing Classes:
ChannelBuffer, ChannelBufferWithFallback, ChannelFileBuffer, ChannelZeroBuffer

public interface ChannelQueue<T> extends ChannelTransformer<T,T>, io.activej.async.process.AsyncCloseable
Represents a queue of elements, which you can put or take to pass from ChannelConsumer to ChannelSupplier.
  • Field Summary

    Fields inherited from interface io.activej.async.process.AsyncCloseable

    STATIC
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a ChannelConsumer which puts value in this queue when accept(T value) is called.
    getConsumer(io.activej.promise.Promise<Void> acknowledgement)
    Returns a ChannelConsumer which puts non-null value in this queue when accept(T value) is called.
    Returns a ChannelSupplier which gets value from this queue wrapped in Promise when get() is called.
    boolean
     
    boolean
     
    io.activej.promise.Promise<Void>
    put(T item)
    Puts an item in the queue and returns a promise of null as a marker of completion.
    io.activej.promise.Promise<T>
    Takes an element of this queue and wraps it in promise.
     
     

    Methods inherited from interface io.activej.async.process.AsyncCloseable

    close, closeEx
  • Method Details

    • put

      io.activej.promise.Promise<Void> put(@Nullable T item)
      Puts an item in the queue and returns a promise of null as a marker of completion.
      Parameters:
      item - a item passed to the queue
      Returns:
      promise of null as a marker of completion
    • take

      io.activej.promise.Promise<T> take()
      Takes an element of this queue and wraps it in promise.
      Returns:
      a promise of value from the queue
    • isSaturated

      boolean isSaturated()
    • isExhausted

      boolean isExhausted()
    • getConsumer

      default ChannelConsumer<T> getConsumer()
      Returns a ChannelConsumer which puts value in this queue when accept(T value) is called.
      Returns:
      a ChannelConsumer for this queue
    • getConsumer

      default ChannelConsumer<T> getConsumer(io.activej.promise.Promise<Void> acknowledgement)
      Returns a ChannelConsumer which puts non-null value in this queue when accept(T value) is called. Otherwise, puts null and waits for the acknowledgement completion.

      This method is useful if you need to control the situations when there are no more elements to be accepted (for example, get a ChannelSupplier in such case).

      Parameters:
      acknowledgement - a promise which will work when a null value is passed
      Returns:
      a ChannelConsumer with custom behaviour in case a null value is accepted
    • getSupplier

      default ChannelSupplier<T> getSupplier()
      Returns a ChannelSupplier which gets value from this queue wrapped in Promise when get() is called.
      Returns:
      a ChannelSupplier which takes values from this queue
    • transform

      default ChannelConsumer<T> transform(ChannelConsumer<T> consumer)
      Specified by:
      transform in interface ChannelConsumerTransformer<T,ChannelConsumer<T>>
    • transform

      default ChannelSupplier<T> transform(ChannelSupplier<T> supplier)
      Specified by:
      transform in interface ChannelSupplierTransformer<T,ChannelSupplier<T>>