Documentation

Amp

Table of Contents

Namespaces

Future
ByteStream
Cache
Dns
Parallel
Parser
Pipeline
Process
Serialization
Socket
Sync

Interfaces

Cancellation
Cancellations are simple objects that allow registering handlers to subscribe to cancellation requests.
Closable

Classes

CancelledException
Will be thrown in case an operation is cancelled.
CompositeCancellation
CompositeException
CompositeLengthException
DeferredCancellation
A deferred cancellation provides a mechanism to cancel operations dynamically.
DeferredFuture
Future
Interval
This object invokes the given callback within a new coroutine every $interval seconds until either the {@see self::disable()} method is called or the object is destroyed.
NullCancellation
A NullCancellation can be used to avoid conditionals to check whether a cancellation has been provided.
SignalCancellation
A SignalCancellation automatically requests cancellation when a given signal is received.
SignalException
Used as the previous exception to {@see CancelledException} when a {@see SignalCancellation} is triggered.
TimeoutCancellation
A TimeoutCancellation automatically requests cancellation after the timeout has elapsed.
TimeoutException
Used as the previous exception to {@see CancelledException} when a {@see TimeoutCancellation} expires.

Traits

ForbidCloning
ForbidSerialization

Functions

async()  : Future<string|int, T>
Creates a new fiber to execute the given closure asynchronously. A Future is returned which is completed with the return value of the passed closure or will fail if the closure throws an exception.
now()  : float
Returns the current time relative to an arbitrary point in time.
delay()  : void
Non-blocking sleep for the specified number of seconds.
trapSignal()  : int
Wait for signal(s) in a non-blocking way.
weakClosure()  : TClosure
Returns a Closure that maintains a weak reference to any $this object held by the Closure (a weak-Closure).

Functions

async()

Creates a new fiber to execute the given closure asynchronously. A Future is returned which is completed with the return value of the passed closure or will fail if the closure throws an exception.

async(Closure $closure, mixed ...$args) : Future<string|int, T>
Parameters
$closure : Closure
$args : mixed

Arguments forwarded to the closure when starting the fiber.

Tags
template
Return values
Future<string|int, T>

now()

Returns the current time relative to an arbitrary point in time.

now() : float
Return values
float

Time in seconds.

delay()

Non-blocking sleep for the specified number of seconds.

delay(float $timeout[, bool $reference = true ][, Cancellation|null $cancellation = null ]) : void
Parameters
$timeout : float

Number of seconds to wait.

$reference : bool = true

If false, unreference the underlying watcher.

$cancellation : Cancellation|null = null

Cancel waiting if cancellation is requested.

trapSignal()

Wait for signal(s) in a non-blocking way.

trapSignal(int|array<string|int, int> $signals[, bool $reference = true ][, Cancellation|null $cancellation = null ]) : int
Parameters
$signals : int|array<string|int, int>

Signal number or array of signal numbers.

$reference : bool = true

If false, unreference the underlying watcher.

$cancellation : Cancellation|null = null

Cancel waiting if cancellation is requested.

Tags
throws
UnsupportedFeatureException
Return values
int

Caught signal number.

weakClosure()

Returns a Closure that maintains a weak reference to any $this object held by the Closure (a weak-Closure).

weakClosure(TClosure $closure) : TClosure

This allows a class to hold a self-referencing Closure without creating a circular reference that would prevent or delay automatic garbage collection. Invoking the returned Closure after the object is destroyed will throw an instance of Error.

Parameters
$closure : TClosure
Tags
template
Return values
TClosure

        
On this page

Search results