phasync
WriteChannelInterface / write

Method

WriteChannelInterface::write

Sends a value, and waits while the channel cannot take it: for a reader on an unbuffered channel, for room on a full buffer.

Description#

public WriteChannelInterface::write(
    mixed $value,
    float $timeout = PHP_FLOAT_MAX
): void

Any value is accepted: a channel is in-memory communication between coroutines of one process, and nothing is serialized.

Parameters#

$value mixed
What to send
$timeout float = PHP_FLOAT_MAX
Seconds to wait at most

Errors / Exceptions#

ExceptionWhen
ChannelExceptionIf the channel is closed, or the creator of the channel waits on it alone, see WriteChannelInterface::activate
TimeoutExceptionIf the value could not be sent in time

See also#