# Package groovy.concurrent

## Package groovy.concurrent Description

Structured concurrency abstractions for asynchronous and parallel programming.

Language-facing async types:

- Awaitable — async computation handle and static combinator surface used with the `await` keyword
- AwaitResult — success/failure value from Awaitable.allSettled
- AsyncScope — structured concurrency
- AsyncChannel — CSP-style async channel
- AwaitableAdapter / AwaitableAdapterRegistry — SPI for third-party async types (RxJava, Reactor, …)

Additional high-level primitives: Actor (message-passing), groovy.concurrent.Pool (thread management), and groovy.concurrent.ParallelScope (combined async+parallel). Supports virtual threads (JDK 21+) and fail-fast exception handling. Runtime implementation details live in `org.apache.groovy.runtime.async`.

- Interface Summary
  Interface | Description
  --- | ---
  Actor | A lightweight message-passing actor for concurrent state management.
  ActorContext | Context handle passed to context-aware actor handlers.
  AsyncChannel | An asynchronous channel for inter-task communication with optional buffering.
  AsyncScope | A structured concurrency scope that ensures all child tasks complete (or are cancelled) before the scope exits.
  Awaitable | Core abstraction for asynchronous computations in Groovy.
  AwaitableAdapter | Service Provider Interface (SPI) for adapting third-party asynchronous types to Groovy's Awaitable abstraction and to iterables for `for await` loops.
  Cancellable | A handle for a scheduled action that can be called off before it fires (or that can have its further firings suppressed, in the case of a recurring schedule).
  Pool | A managed thread pool for parallel and concurrent operations.
  ReactorHandler | Context-aware handler for reactor actors.
  StatefulHandler | Context-aware handler for stateful actors.

- Class Summary
  Class | Description
  --- | ---
  Agent | A thread-safe mutable-value container inspired by Clojure's agents and GPars' `Agent`.
  AwaitResult | Represents the outcome of an asynchronous computation that may have succeeded or failed.
  AwaitableAdapterRegistry | Central registry for AwaitableAdapter instances.
  BroadcastChannel | A one-to-many broadcast channel where each value sent is delivered to all subscribers.
  ChannelSelect | Selects the first available value from multiple AsyncChannels.
  ChannelSelect.Result | The result of a select() operation, indicating which channel produced the value.
  ConcurrentConfig | Central configuration for Groovy's concurrent and parallel features.
  DataflowVariable | A single-assignment variable for dataflow-style programming.
  Dataflows | A dynamic map of DataflowVariable instances, providing a concise syntax for dataflow-style programming.
  ParallelScope | Convenience API for running work within a pool-isolated AsyncScope.

- Enum Summary
  Enum | Description
  --- | ---
  ActorOptions.Overflow | Policy applied when Actor.send is called on an actor whose bounded mailbox is full.
  ActorOptions.StashOverflow | Policy applied when ActorContext.stash is called and the actor's bounded stash is already at capacity.

- Exception Summary
  Exception | Description
  --- | ---
  ChannelClosedException | Thrown when an AsyncChannel operation is attempted after the channel has been closed.