This is automatic generated document for things in Swow\Channel class

Class Channel

channel transfers information across coroutines

This class is a generic class. Template T

Methods

Method __construct

public function __construct ( int $capacity )

Create a channel.

Param int $capacity 0 is unbuffered. -1 is unlimited.

Throws \ValueError when the capacity is negative and not -1

Method __debugInfo

public function __debugInfo ( ) : array<string, mixed>

Returns array<string, mixed> debug information for var_dump

Method close

public function close ( ) : void

Close the channel.

A queued value can still be popped. A waiting coroutine wakes with error code -125.

Throws ChannelException when the channel is already closed

Method getCapacity

public function getCapacity ( ) : int

Method getLength

public function getLength ( ) : int

Method hasConsumers

public function hasConsumers ( ) : bool

Method hasProducers

public function hasProducers ( ) : bool

Method isAvailable

public function isAvailable ( ) : bool

Method isEmpty

public function isEmpty ( ) : bool

Method isFull

public function isFull ( ) : bool

Method isReadable

public function isReadable ( ) : bool

Method isWritable

public function isWritable ( ) : bool

Method pop

public function pop ( int $timeout ) : T

pop data from channel

context switching happens here when channel is empty, context switching may also happen at this even channel is not empty.

Param int $timeout in milliseconds

Returns T $data

Throws ChannelException on timeout (-110) or when the channel is closed (-9758)

Method push

public function push ( T $data , int $timeout ) : static

push data into channel

context switching happens here when channel is full, context switching may also happen at this even channel is not full.

Throws ChannelException on timeout (-110) or when the channel is closed (-9758)


Copyright 2022 the Swow contributors

This site uses Just the Docs, a documentation theme for Jekyll.