Channel
final class Channel (View source)
Unbuffered Channels
An unbuffered channel will block on calls to Channel::send() until there is a receiver, and block on calls to Channel::recv() until there is a sender. This means an unbuffered channel is not only a way to share data among tasks but also a simple method of synchronization.
An unbuffered channel is the fastest way to share data among tasks, requiring the least copying.
Buffered Channels
A buffered channel will not block on calls to Channel::send() until capacity is reached, calls to
Constants
Infinite |
Constant for Infinitely Buffered |
Methods
Shall make an anonymous unbuffered channel Shall make an anonymous buffered channel with the given capacity
Shall make an unbuffered channel with the given name Shall make a buffered channel with the given name and capacity
Shall send the given value on this channel
Shall recv a value from this channel
Shall close this channel
Returns name of channel
Details
__construct(int|null $capacity = null)
Shall make an anonymous unbuffered channel Shall make an anonymous buffered channel with the given capacity
static Channel
make(string $name, int|null $capacity = null)
Shall make an unbuffered channel with the given name Shall make a buffered channel with the given name and capacity
static Channel
open(string $name)
Shall open the channel with the given name
void
send(mixed $value)
Shall send the given value on this channel
mixed
recv()
Shall recv a value from this channel
void
close()
Shall close this channel
string
__toString()
Returns name of channel