Nexus API Reference

FiberFutureSlot
in package
implements FutureSlot

FinalYes

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
implements

FutureSlot

Table of Contents

Interfaces

FutureSlot

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.

isResolved()

Whether the slot has been resolved or failed.

public isResolved() : bool
Return values
bool

onCancel()

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

        
On this page

Search results