diff --git a/src/ExtEventLoop.php b/src/ExtEventLoop.php index 48657f96..58f7022f 100644 --- a/src/ExtEventLoop.php +++ b/src/ExtEventLoop.php @@ -5,8 +5,7 @@ use Event; use EventBase; use EventConfig as EventBaseConfig; -use React\EventLoop\Tick\FutureTickQueue; -use React\EventLoop\Tick\NextTickQueue; +use React\EventLoop\Tick\TickQueue; use React\EventLoop\Timer\Timer; use React\EventLoop\Timer\TimerInterface; use SplObjectStorage; @@ -31,8 +30,8 @@ class ExtEventLoop implements LoopInterface public function __construct(EventBaseConfig $config = null) { $this->eventBase = new EventBase($config); - $this->nextTickQueue = new NextTickQueue($this); - $this->futureTickQueue = new FutureTickQueue($this); + $this->nextTickQueue = new TickQueue($this); + $this->futureTickQueue = new TickQueue($this); $this->timerEvents = new SplObjectStorage(); $this->createTimerCallback(); diff --git a/src/LibEvLoop.php b/src/LibEvLoop.php index 38e4ec2c..a2b8d535 100644 --- a/src/LibEvLoop.php +++ b/src/LibEvLoop.php @@ -5,8 +5,7 @@ use libev\EventLoop; use libev\IOEvent; use libev\TimerEvent; -use React\EventLoop\Tick\FutureTickQueue; -use React\EventLoop\Tick\NextTickQueue; +use React\EventLoop\Tick\TickQueue; use React\EventLoop\Timer\Timer; use React\EventLoop\Timer\TimerInterface; use SplObjectStorage; @@ -28,8 +27,8 @@ class LibEvLoop implements LoopInterface public function __construct() { $this->loop = new EventLoop(); - $this->nextTickQueue = new NextTickQueue($this); - $this->futureTickQueue = new FutureTickQueue($this); + $this->nextTickQueue = new TickQueue($this); + $this->futureTickQueue = new TickQueue($this); $this->timerEvents = new SplObjectStorage(); } diff --git a/src/LibEventLoop.php b/src/LibEventLoop.php index 6fbc8269..a0d43278 100644 --- a/src/LibEventLoop.php +++ b/src/LibEventLoop.php @@ -4,8 +4,7 @@ use Event; use EventBase; -use React\EventLoop\Tick\FutureTickQueue; -use React\EventLoop\Tick\NextTickQueue; +use React\EventLoop\Tick\TickQueue; use React\EventLoop\Timer\Timer; use React\EventLoop\Timer\TimerInterface; use SplObjectStorage; @@ -32,8 +31,8 @@ class LibEventLoop implements LoopInterface public function __construct() { $this->eventBase = event_base_new(); - $this->nextTickQueue = new NextTickQueue($this); - $this->futureTickQueue = new FutureTickQueue($this); + $this->nextTickQueue = new TickQueue($this); + $this->futureTickQueue = new TickQueue($this); $this->timerEvents = new SplObjectStorage(); $this->createTimerCallback(); diff --git a/src/StreamSelectLoop.php b/src/StreamSelectLoop.php index 7d455048..8ba33507 100644 --- a/src/StreamSelectLoop.php +++ b/src/StreamSelectLoop.php @@ -2,8 +2,7 @@ namespace React\EventLoop; -use React\EventLoop\Tick\FutureTickQueue; -use React\EventLoop\Tick\NextTickQueue; +use React\EventLoop\Tick\TickQueue; use React\EventLoop\Timer\Timer; use React\EventLoop\Timer\TimerInterface; use React\EventLoop\Timer\Timers; @@ -26,8 +25,8 @@ class StreamSelectLoop implements LoopInterface public function __construct() { - $this->nextTickQueue = new NextTickQueue($this); - $this->futureTickQueue = new FutureTickQueue($this); + $this->nextTickQueue = new TickQueue($this); + $this->futureTickQueue = new TickQueue($this); $this->timers = new Timers(); } diff --git a/src/Tick/NextTickQueue.php b/src/Tick/NextTickQueue.php deleted file mode 100644 index 5b8e1de8..00000000 --- a/src/Tick/NextTickQueue.php +++ /dev/null @@ -1,57 +0,0 @@ -eventLoop = $eventLoop; - $this->queue = new SplQueue(); - } - - /** - * Add a callback to be invoked on the next tick of the event loop. - * - * Callbacks are guaranteed to be executed in the order they are enqueued, - * before any timer or stream events. - * - * @param callable $listener The callback to invoke. - */ - public function add(callable $listener) - { - $this->queue->enqueue($listener); - } - - /** - * Flush the callback queue. - */ - public function tick() - { - while (!$this->queue->isEmpty()) { - call_user_func( - $this->queue->dequeue(), - $this->eventLoop - ); - } - } - - /** - * Check if the next tick queue is empty. - * - * @return boolean - */ - public function isEmpty() - { - return $this->queue->isEmpty(); - } -} diff --git a/src/Tick/FutureTickQueue.php b/src/Tick/TickQueue.php similarity index 92% rename from src/Tick/FutureTickQueue.php rename to src/Tick/TickQueue.php index eeffd363..7ab02885 100644 --- a/src/Tick/FutureTickQueue.php +++ b/src/Tick/TickQueue.php @@ -5,7 +5,7 @@ use React\EventLoop\LoopInterface; use SplQueue; -class FutureTickQueue +class TickQueue { private $eventLoop; private $queue; @@ -20,7 +20,7 @@ public function __construct(LoopInterface $eventLoop) } /** - * Add a callback to be invoked on a future tick of the event loop. + * Add a callback to be invoked on a tick of the event loop. * * Callbacks are guaranteed to be executed in the order they are enqueued. *