Package: org.apache.groovy.runtime.async

## [Java] Class DefaultAsyncChannel<T>

- org.apache.groovy.runtime.async.DefaultAsyncChannel

- All Implemented Interfaces and Traits:
    AsyncChannel

      public final class DefaultAsyncChannel<T>
      extends Object
      implements AsyncChannel

  Default lock-based implementation of AsyncChannel.

  Uses a ReentrantLock to coordinate access to the internal buffer and the waiting-sender/waiting-receiver queues. All operations return Awaitable immediately; the underlying CompletableFuture is completed asynchronously when matching counterparts arrive.

  Type Parameters:
    `T` - the payload type
  See Also:
    AsyncChannel
  Since:
    6.0.0

- - ### Constructor Summary

    Constructors
    Constructor and description
    `DefaultAsyncChannel()`
    `DefaultAsyncChannel(int capacity)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public boolean` | `close()`
    `` | `public int` | `getBufferedSize()`
    `` | `public int` | `getCapacity()`
    `` | `public boolean` | `isClosed()`
    `` | `public Iterator<T>` | `iterator()` Returns a blocking iterator that receives values until the channel is closed and drained.
    `` | `public Awaitable<T>` | `receive()`
    `` | `public Awaitable<Void>` | `send(T value)`
    `` | `public String` | `toString()`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### public DefaultAsyncChannel()

    - #### public DefaultAsyncChannel(int capacity)

  - ### Method Detail

    - #### public boolean close()

    - #### public int getBufferedSize()

    - #### public int getCapacity()

    - #### public boolean isClosed()

    - #### public Iterator<T> iterator()

      Returns a blocking iterator that receives values until the channel is closed and drained. Each `next()` call blocks until a value is available. ChannelClosedException signals end-of-iteration.

    - #### public Awaitable<T> receive()

    - #### public Awaitable<Void> send(T value)

    - #### public String toString()