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.

  Every operation is arbitrated by a SelectClaim: the branches of a ChannelSelect share their select's claim, and a plain operation carries a private one. The claim is the sole owner of a parked operation's fate — a delivery commits it before it completes the future, and cancellation must commit it before it may touch the future — so a select over sends and receives on several channels commits exactly one transfer, and a losing branch never disturbs its channel.

  Both waiting queues are concurrent deques so that a cancelled operation can withdraw itself without taking the channel lock: a ChannelSelect withdraws its losing branches from inside the winning channel's delivery, and taking a second channel's lock there could deadlock against a select completing on that channel.

  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()