Documentation

Channel extends Closable
in

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

Tags
template-covariant
template

Table of Contents

Methods

close()  : void
Closes the resource, marking it as unusable.
isClosed()  : bool
Returns whether this resource has been closed.
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.

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