This is automatic generated document for things in Swow\Thannel class
Class Thannel
A queue that transfers serialized values between threads.
The capacity is a value count. Capacity 0 is unbuffered. Capacity -1 is unlimited. Values are serialized. A resource becomes 0. A closure cannot be passed. An unbuffered push waits for the consumer. In one OS thread the push does not return after the take. Use an unbuffered Thannel only across threads.
Methods
Method __construct
Create a Thannel. This method does not yield.
Param int $capacity capacity is -1 or between 0 and UINT32_MAX
Throws \ValueError when the capacity is out of range. Throws ThannelException when the Thannel is already constructed.
Method __debugInfo
Return debug information.
Method __serialize
Serialize the Thannel by shared object id.
The serialized form does not copy the queue.
Throws ThannelException when the Thannel is not constructed.
Method __unserialize
Restore the Thannel from a shared object id.
Throws ThannelException when the data is invalid or the object is gone.
Method close
Close the queue.
Queued values stay available. A later push is rejected. A second close() does nothing.
Throws ThannelException when the queue is not constructed or close fails.
Method drain
Remove all queued values without waiting.
Method getCapacity
Return the queue capacity.
Method getLength
Return the number of queued values.
Method getParkCount
Return the number of times a side parked.
Method getWakeCount
Return the number of wakes that reached a waiter.
Method isClosed
Return true after the queue is closed.
Method isEmpty
Return true when the queue has no values.
Method isFull
Return true when the queue is full. An unbuffered Thannel is always full.
Method pop
Remove a value and unserialize it.
In a coroutine, this method suspends the current coroutine when the queue is empty.
context switching may happen here
Param int $timeout timeout in milliseconds, -1 waits forever
Throws ThannelException when the wait times out, the queue is closed and empty, or the value cannot be unserialized.
Method popMany
Remove up to max values.
The call returns at least one value when the queue is not empty.
context switching may happen here
Param int $max maximum number of values to return Param int $timeout timeout in milliseconds, -1 waits forever
Returns array the values in queue order
Method push
Serialize a value and add it to the queue.
In a coroutine, this method suspends the current coroutine when the queue is full. An unbuffered push in one OS thread does not return after the take. The timeout does not fire.
context switching may happen here
Param mixed $data value to serialize Param int $timeout timeout in milliseconds, -1 waits forever
Throws ThannelException on timeout (-110) or when the queue is closed (-9758) Throws \Exception when the value cannot be serialized
Method pushMany
Serialize a batch and push it as one unit.
The batch enters as a whole or not at all. In a coroutine, this method suspends the current coroutine when the batch does not fit.
context switching may happen here
Param array $values values to serialize Param int $timeout timeout in milliseconds, -1 waits forever
Returns int number of values pushed
Throws ThannelException on timeout, a closed queue, or an oversized batch
Method willBlock
Returns bool true when the queue is empty or full. An unbuffered Thannel always returns true.