1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace Elgg\Queue;
- /**
- * FIFO queue that is memory based (not persistent)
- *
- * WARNING: API IN FLUX. DO NOT USE DIRECTLY.
- *
- * @access private
- *
- * @package Elgg.Core
- * @subpackage Queue
- * @since 1.9.0
- */
- class MemoryQueue implements \Elgg\Queue\Queue {
- /* @var array */
- protected $queue = array();
- /**
- * Create a queue
- */
- public function __construct() {
- $this->queue = array();
- }
- /**
- * {@inheritdoc}
- */
- public function enqueue($item) {
- return (bool)array_push($this->queue, $item);
- }
- /**
- * {@inheritdoc}
- */
- public function dequeue() {
- return array_shift($this->queue);
- }
- /**
- * {@inheritdoc}
- */
- public function clear() {
- $this->queue = array();
- }
- /**
- * {@inheritdoc}
- */
- public function size() {
- return count($this->queue);
- }
- }
|