Nexus API Reference

FutureSlot

Tags
psalm-api

Internal resolution mechanism for Future-based ask pattern.

Each runtime provides its own implementation using runtime-specific suspension primitives (Fiber::suspend, Swoole Channel, etc.).

template

R of object

Table of Contents

Methods

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

await()

Block the current fiber/coroutine until the slot is resolved or failed.

public await() : R
Tags
throws
FutureException

The failure exception if fail() was called

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
bool

onCancel()

Register a callback invoked when cancel() transitions the slot into terminal cancelled state.

public onCancel(callable(): void $callback) : void
Parameters
$callback : callable(): void

resolve()

Resolve the slot with a value. Idempotent - second call is a no-op.

public resolve(R $value) : void

Wakes the awaiting fiber/coroutine if one is suspended.

Parameters
$value : R

        
On this page

Search results