This is automatic generated document for things in Swow\SpscQueue class
Class SpscQueue
A fixed-size single-producer single-consumer queue in shared memory.
One thread produces and one thread consumes. A blocking call stops the whole OS thread, so use it only in a worker that runs one coroutine. An anonymous queue is visible to threads of this process and to a forked child. A named queue is visible to another process that attaches the same name.
Methods
Static method attachNamed
Attach a named queue.
Static method createNamed
Create a named queue.
Throws \ValueError when a size is out of range Throws SpscQueueException when the name exists or the queue cannot be created
Static method unlink
Remove a name.
An existing mapping stays valid. On Windows the section ends when the last mapping closes; unlink does not remove the name earlier.
Method __construct
Create an anonymous queue.
Param int $capacity maximum number of queued values Param int $maxMessageSize maximum size of one serialized value in bytes
Throws \ValueError when a size is out of range Throws SpscQueueException when the queue cannot be created
Method __debugInfo
Return debug information.
Method __serialize
Serialize the queue by name or shared object id.
The serialized form does not copy queued values.
Method __unserialize
Restore the queue from a name or shared object id.
Method close
Stop further pushes and wake both sides.
Method drain
Pop all queued values without waiting.
Method getCapacity
Return the maximum number of queued values.
Method getLength
Return the number of queued values.
Method getMaxMessageSize
Return the maximum serialized value size in bytes.
Method getName
Return the name, or null for an anonymous queue.
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 close.
Method isEmpty
Return true when the queue has no values.
Method isFull
Return true when the queue has no free slot.
Method pop
Pop and unserialize a value.
this method blocks the whole OS thread
Param int $timeout timeout in milliseconds, -1 waits forever
Throws SpscQueueException on timeout, a closed empty queue, or a deserialization failure
Method popMany
Pop up to max values.
The call returns at least one value when the queue is not empty.
this method blocks the whole OS thread
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 push it.
this method blocks the whole OS thread
Param mixed $value value to serialize Param int $timeout timeout in milliseconds, -1 waits forever
Throws SpscQueueException on timeout, a closed queue, or a serialization failure
Method pushMany
Serialize a batch and push it as one unit.
The batch enters as a whole or not at all.
this method blocks the whole OS thread
Param array $values values to serialize Param int $timeout timeout in milliseconds, -1 waits forever
Returns int number of values pushed
Throws SpscQueueException on timeout, a closed queue, or an oversized batch