Interface
QueueInterface
A first-in first-out queue that coroutines may share.
Class synopsis#
interface QueueInterface extends \Countable, LockInterface {
/* Methods */
public QueueInterface::isEmpty(): bool
public QueueInterface::enqueue(mixed $value): void
public QueueInterface::tryDequeue(mixed &$value): bool
public QueueInterface::tryPeek(mixed &$value): bool
}Methods#
| Method | Description |
|---|---|
isEmpty | Returns true if the queue holds no values. |
enqueue | Adds $value at the end of the queue. |
tryDequeue | Takes the first value off the queue into $value, and returns whether there was one. |
tryPeek | Copies the first value of the queue into $value, without removing it, and returns whether there was one. |
Examples#
$queue = new phasync\Util\Queue();
$queue->enqueue('job');
if ($queue->tryDequeue($job)) {
echo $job; // job
}See also#
QueueA first-in first-out queue whose operations take a lock, so coroutines may share it.