LazyFutureSlot
in package
implements
FutureSlot
FinalYes
A FutureSlot that lazily evaluates a closure on await().
Used internally by Future combinators (map, flatMap).
Tags
Table of Contents
Interfaces
Methods
- __construct() : mixed
- await() : R
- Block the current fiber/coroutine until the slot is resolved or failed.
- cancel() : void
- Cancel the slot. Idempotent - second call is a no-op.
- fail() : void
- Fail the slot with an exception. Idempotent - second call is a no-op.
- isResolved() : bool
- Whether the slot has been resolved or failed.
- onCancel() : void
- Register a callback invoked when cancel() transitions the slot into terminal cancelled state.
- resolve() : void
- Resolve the slot with a value. Idempotent - second call is a no-op.
Methods
__construct()
public
__construct(callable(): R $computation) : mixed
Parameters
- $computation : callable(): R
await()
Block the current fiber/coroutine until the slot is resolved or failed.
public
await() : R
Attributes
- #[Override]
Return values
R —The resolved value
cancel()
Cancel the slot. Idempotent - second call is a no-op.
public
cancel() : void
Wakes the awaiting fiber/coroutine if one is suspended.
Attributes
- #[Override]
fail()
Fail the slot with an exception. Idempotent - second call is a no-op.
public
fail(FutureException $e) : void
Wakes the awaiting fiber/coroutine if one is suspended.
Parameters
- $e : FutureException
Attributes
- #[Override]
isResolved()
Whether the slot has been resolved or failed.
public
isResolved() : bool
Attributes
- #[Override]
Return values
boolonCancel()
Register a callback invoked when cancel() transitions the slot into terminal cancelled state.
public
onCancel(Closure $callback) : void
Parameters
- $callback : Closure
Attributes
- #[Override]
resolve()
Resolve the slot with a value. Idempotent - second call is a no-op.
public
resolve(object $value) : void
Wakes the awaiting fiber/coroutine if one is suspended.
Parameters
- $value : object
Attributes
- #[Override]