Documentation

StreamChannel
in package
implements Channel uses ForbidCloning, ForbidSerialization

FinalYes

An asynchronous channel for sending data between threads and processes.

Supports full duplex read and write.

Tags
template
template
template-implements

Table of Contents

Interfaces

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

Properties

$parser  : ChannelParser
$read  : ReadableStream
$readMutex  : Mutex
$received  : SplQueue<string|int, TReceive>
$write  : WritableStream

Methods

__construct()  : mixed
Creates a new channel from the given stream objects. Note that $read and $write can be the same object.
__destruct()  : mixed
__serialize()  : never
__unserialize()  : never
close()  : void
Closes the read and write resource streams.
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
__clone()  : mixed

Properties

$received read-only

private SplQueue<string|int, TReceive> $received

Methods

__unserialize()

public final __unserialize(array<string|int, mixed> $data) : never
Parameters
$data : array<string|int, mixed>
Return values
never

close()

Closes the read and write resource streams.

public close() : void

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(Closure $onClose) : void
Parameters
$onClose : Closure

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.

Return values
TReceive

Data received.

send()

public send(mixed $data) : void
Parameters
$data : mixed

        
On this page

Search results