FiberFutureSlot
in package
implements
FutureSlot
Fiber-based FutureSlot implementation.
Suspends the calling fiber on await(). Resumes it when resolve() or fail() is called. Uses a wakeup callback to signal the runtime that a fiber needs resumption.
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(): void $onResolve) : mixed
Parameters
- $onResolve : callable(): void
-
Callback to signal the runtime (sets wakeupPending)
await()
Block the current fiber/coroutine until the slot is resolved or failed.
public
await() : R
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.
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
isResolved()
Whether the slot has been resolved or failed.
public
isResolved() : bool
Return values
boolonCancel()
Register a callback invoked when cancel() transitions the slot into terminal cancelled state.
public
onCancel(Closure $callback) : void
Parameters
- $callback : Closure
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