Documentation

Context extends Channel
in

Interface for sending messages between execution contexts, such as two coroutines or two processes.

Tags
template-covariant
template-covariant
template
extends

Table of Contents

Methods

close()  : void
Closes the resource, marking it as unusable.
isClosed()  : bool
Returns whether this resource has been closed.
join()  : TResult
onClose()  : void
Registers a callback that is invoked when this resource is closed.
receive()  : TReceive
send()  : void

Methods

close()

Closes the resource, marking it as unusable.

public close() : void

Whether pending operations are aborted or not is implementation dependent.

isClosed()

Returns whether this resource has been closed.

public isClosed() : bool
Return values
bool

true if closed, otherwise false.

join()

public join([Cancellation|null $cancellation = null ]) : TResult
Parameters
$cancellation : Cancellation|null = null
Tags
throws
ContextException

If the context exited with an uncaught exception or non-zero code.

Return values
TResult

The data returned from the context. This method may be called at any time to await the result or an exception will be thrown if the context is closed or throws an exception or exits with a non-zero code.

onClose()

Registers a callback that is invoked when this resource is closed.

public onClose(callable(): void $onClose) : void
Parameters
$onClose : callable(): void

receive()

public receive([Cancellation|null $cancellation = null ]) : TReceive
Parameters
$cancellation : Cancellation|null = null

Cancels waiting for the next value. Note the next value is not discarded if the operation is cancelled, rather it will be returned from the next call to this method.

Tags
throws
ChannelException

If receiving from the channel fails or the channel closed.

throws
SerializationException

If the underlying transport mechanism uses serialization and fails.

Return values
TReceive

Data received.

send()

public send(TSend $data) : void
Parameters
$data : TSend
Tags
throws
ChannelException

If sending on the channel fails or the channel is already closed.

throws
SerializationException

If the underlying transport mechanism uses serialization and fails.


        
On this page

Search results