Package org.apache.groovy.runtime.async

# Class ScopedLocal.Carrier

java.lang.Object
org.apache.groovy.runtime.async.ScopedLocal.Carrier

Enclosing class:
  ScopedLocal<T>

public static final class ScopedLocal.Carrier extends Object
An immutable set of scoped-local bindings that can be applied atomically for the duration of a `Runnable` or `Supplier`.

Since:
  6.0.0

- ## Method Summary

  Modifier and Type
  Method
  Description
  `<R> R`
  `call(Supplier<R> supplier)`
  Executes the supplier with all bindings in this carrier active and returns its result.
  `void`
  `run(Runnable action)`
  Executes the action with all bindings in this carrier active.
  `<T> ScopedLocal.Carrier`
  `where(ScopedLocal<T> key, T value)`
  Adds another binding to this carrier, returning a new carrier that includes all previous bindings plus the new one.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### where

    public <T> ScopedLocal.Carrier where(ScopedLocal<T> key, T value)
    Adds another binding to this carrier, returning a new carrier that includes all previous bindings plus the new one.
    Type Parameters:
      `T` - the value type
    Parameters:
      `key` - the scoped-local to bind
      `value` - the value to bind; may be `null`
    Returns:
      a new carrier with the additional binding

  - ### run

    public void run(Runnable action)
    Executes the action with all bindings in this carrier active.
    Parameters:
      `action` - the action to execute

  - ### call

    public <R> R call(Supplier<R> supplier)
    Executes the supplier with all bindings in this carrier active and returns its result.
    Type Parameters:
      `R` - the result type
    Parameters:
      `supplier` - the supplier to execute
    Returns:
      the supplier's result