phasync\Internal\ChannelBuffered final class

Documentation

This is a highly optimized implementation of a bi-directional channel for communication between coroutines running in the same memory space without threading. It is not meant to be used directly since it has no protection against deadlocks. Instead channels should be created via phasync::channel().

The implementation reaches around 500 000 reads and 500 000 writes between a pair of coroutines on an AMD Ryzen 7 2700X.

Inheritance

Implements: phasync\Internal\ChannelBackendInterface IteratorAggregate phasync\SelectableInterface Traversable phasync\WriteChannelInterface phasync\ReadChannelInterface

Constants (3)

NameValue
READY 0
BLOCKING_READS 1
BLOCKING_WRITES 2

Properties (15)

private static array $waiting

Waiting readers must be stored here, because if the Channel becomes

private WeakMap $timeouts

The timeout for waiting fibers.

private int $id
private bool $closed
private array $buffer
private ?Fiber $creatingFiber
private int $state
private int $queueFirst
private int $queueLast
private int $queueFailed
private int $bufferSize
private int $firstBuffer
private int $lastBuffer
private ?Fiber $receiver
private object $flag

Methods (19)

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Source

src/Internal/ChannelBuffered.php:21-317