Future
in package
Read onlyYes
FinalYes
Tags
Table of Contents
Methods
- __construct() : mixed
- all() : Future<string|int, FutureResult<string|int, object>>
- Wait for all futures and collect their results, keyed identically to the input.
- await() : R
- Block the current fiber until the result is available.
- cancel() : void
- failed() : self
- Create a Future that is already failed.
- flatMap() : Future<string|int, U>
- Chain a dependent ask. Lazy - does not block.
- isResolved() : bool
- map() : Future<string|int, U>
- Transform the result when it arrives. Lazy - does not block.
- onCancel() : self
- Register a callback invoked when this future is cancelled.
- resolved() : self
- Create a Future that is already completed with the given value.
Methods
__construct()
public
__construct(FutureSlot<string|int, R> $slot) : mixed
Parameters
- $slot : FutureSlot<string|int, R>
all()
Wait for all futures and collect their results, keyed identically to the input.
public
static all(array<string|int, Future<string|int, object>> $futures) : Future<string|int, FutureResult<string|int, object>>
If any future fails, the combined future fails with the first failure encountered.
Parameters
- $futures : array<string|int, Future<string|int, object>>
Return values
Future<string|int, FutureResult<string|int, object>>await()
Block the current fiber until the result is available.
public
await() : R
Tags
Return values
Rcancel()
public
cancel() : void
failed()
Create a Future that is already failed.
public
static failed(FutureException $error) : self
Parameters
- $error : FutureException
Return values
selfflatMap()
Chain a dependent ask. Lazy - does not block.
public
flatMap(callable(R): Future<string|int, U> $fn) : Future<string|int, U>
Parameters
- $fn : callable(R): Future<string|int, U>
Tags
Return values
Future<string|int, U>isResolved()
public
isResolved() : bool
Return values
boolmap()
Transform the result when it arrives. Lazy - does not block.
public
map(callable(R): U $fn) : Future<string|int, U>
Parameters
- $fn : callable(R): U
Tags
Return values
Future<string|int, U>onCancel()
Register a callback invoked when this future is cancelled.
public
onCancel(callable(): void $callback) : self
Parameters
- $callback : callable(): void
Return values
selfresolved()
Create a Future that is already completed with the given value.
public
static resolved(R2 $value) : self
Parameters
- $value : R2