Skip to content

Commit 1a4c7ea

Browse files
committed
Remove NextTickQueue – use FutureTickQueue instead
1 parent ddfadd9 commit 1a4c7ea

7 files changed

Lines changed: 10 additions & 263 deletions

File tree

src/ExtEventLoop.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use EventBase;
77
use EventConfig as EventBaseConfig;
88
use React\EventLoop\Tick\FutureTickQueue;
9-
use React\EventLoop\Tick\NextTickQueue;
109
use React\EventLoop\Timer\Timer;
1110
use React\EventLoop\Timer\TimerInterface;
1211
use SplObjectStorage;
@@ -17,7 +16,6 @@
1716
class ExtEventLoop implements LoopInterface
1817
{
1918
private $eventBase;
20-
private $nextTickQueue;
2119
private $futureTickQueue;
2220
private $timerCallback;
2321
private $timerEvents;
@@ -31,7 +29,6 @@ class ExtEventLoop implements LoopInterface
3129
public function __construct(EventBaseConfig $config = null)
3230
{
3331
$this->eventBase = new EventBase($config);
34-
$this->nextTickQueue = new NextTickQueue($this);
3532
$this->futureTickQueue = new FutureTickQueue($this);
3633
$this->timerEvents = new SplObjectStorage();
3734

@@ -153,14 +150,6 @@ public function isTimerActive(TimerInterface $timer)
153150
return $this->timerEvents->contains($timer);
154151
}
155152

156-
/**
157-
* {@inheritdoc}
158-
*/
159-
public function nextTick(callable $listener)
160-
{
161-
$this->nextTickQueue->add($listener);
162-
}
163-
164153
/**
165154
* {@inheritdoc}
166155
*/
@@ -174,8 +163,6 @@ public function futureTick(callable $listener)
174163
*/
175164
public function tick()
176165
{
177-
$this->nextTickQueue->tick();
178-
179166
$this->futureTickQueue->tick();
180167

181168
// @-suppression: https://github.com/reactphp/react/pull/234#discussion-diff-7759616R226
@@ -190,12 +177,10 @@ public function run()
190177
$this->running = true;
191178

192179
while ($this->running) {
193-
$this->nextTickQueue->tick();
194-
195180
$this->futureTickQueue->tick();
196181

197182
$flags = EventBase::LOOP_ONCE;
198-
if (!$this->running || !$this->nextTickQueue->isEmpty() || !$this->futureTickQueue->isEmpty()) {
183+
if (!$this->running || !$this->futureTickQueue->isEmpty()) {
199184
$flags |= EventBase::LOOP_NONBLOCK;
200185
} elseif (!$this->streamEvents && !$this->timerEvents->count()) {
201186
break;

src/LibEvLoop.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use libev\IOEvent;
77
use libev\TimerEvent;
88
use React\EventLoop\Tick\FutureTickQueue;
9-
use React\EventLoop\Tick\NextTickQueue;
109
use React\EventLoop\Timer\Timer;
1110
use React\EventLoop\Timer\TimerInterface;
1211
use SplObjectStorage;
@@ -18,7 +17,6 @@
1817
class LibEvLoop implements LoopInterface
1918
{
2019
private $loop;
21-
private $nextTickQueue;
2220
private $futureTickQueue;
2321
private $timerEvents;
2422
private $readEvents = [];
@@ -28,7 +26,6 @@ class LibEvLoop implements LoopInterface
2826
public function __construct()
2927
{
3028
$this->loop = new EventLoop();
31-
$this->nextTickQueue = new NextTickQueue($this);
3229
$this->futureTickQueue = new FutureTickQueue($this);
3330
$this->timerEvents = new SplObjectStorage();
3431
}
@@ -157,14 +154,6 @@ public function isTimerActive(TimerInterface $timer)
157154
return $this->timerEvents->contains($timer);
158155
}
159156

160-
/**
161-
* {@inheritdoc}
162-
*/
163-
public function nextTick(callable $listener)
164-
{
165-
$this->nextTickQueue->add($listener);
166-
}
167-
168157
/**
169158
* {@inheritdoc}
170159
*/
@@ -178,8 +167,6 @@ public function futureTick(callable $listener)
178167
*/
179168
public function tick()
180169
{
181-
$this->nextTickQueue->tick();
182-
183170
$this->futureTickQueue->tick();
184171

185172
$this->loop->run(EventLoop::RUN_ONCE | EventLoop::RUN_NOWAIT);
@@ -193,12 +180,10 @@ public function run()
193180
$this->running = true;
194181

195182
while ($this->running) {
196-
$this->nextTickQueue->tick();
197-
198183
$this->futureTickQueue->tick();
199184

200185
$flags = EventLoop::RUN_ONCE;
201-
if (!$this->running || !$this->nextTickQueue->isEmpty() || !$this->futureTickQueue->isEmpty()) {
186+
if (!$this->running || !$this->futureTickQueue->isEmpty()) {
202187
$flags |= EventLoop::RUN_NOWAIT;
203188
} elseif (!$this->readEvents && !$this->writeEvents && !$this->timerEvents->count()) {
204189
break;

src/LibEventLoop.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Event;
66
use EventBase;
77
use React\EventLoop\Tick\FutureTickQueue;
8-
use React\EventLoop\Tick\NextTickQueue;
98
use React\EventLoop\Timer\Timer;
109
use React\EventLoop\Timer\TimerInterface;
1110
use SplObjectStorage;
@@ -18,7 +17,6 @@ class LibEventLoop implements LoopInterface
1817
const MICROSECONDS_PER_SECOND = 1000000;
1918

2019
private $eventBase;
21-
private $nextTickQueue;
2220
private $futureTickQueue;
2321
private $timerCallback;
2422
private $timerEvents;
@@ -32,7 +30,6 @@ class LibEventLoop implements LoopInterface
3230
public function __construct()
3331
{
3432
$this->eventBase = event_base_new();
35-
$this->nextTickQueue = new NextTickQueue($this);
3633
$this->futureTickQueue = new FutureTickQueue($this);
3734
$this->timerEvents = new SplObjectStorage();
3835

@@ -161,14 +158,6 @@ public function isTimerActive(TimerInterface $timer)
161158
return $this->timerEvents->contains($timer);
162159
}
163160

164-
/**
165-
* {@inheritdoc}
166-
*/
167-
public function nextTick(callable $listener)
168-
{
169-
$this->nextTickQueue->add($listener);
170-
}
171-
172161
/**
173162
* {@inheritdoc}
174163
*/
@@ -182,8 +171,6 @@ public function futureTick(callable $listener)
182171
*/
183172
public function tick()
184173
{
185-
$this->nextTickQueue->tick();
186-
187174
$this->futureTickQueue->tick();
188175

189176
event_base_loop($this->eventBase, EVLOOP_ONCE | EVLOOP_NONBLOCK);
@@ -197,12 +184,10 @@ public function run()
197184
$this->running = true;
198185

199186
while ($this->running) {
200-
$this->nextTickQueue->tick();
201-
202187
$this->futureTickQueue->tick();
203188

204189
$flags = EVLOOP_ONCE;
205-
if (!$this->running || !$this->nextTickQueue->isEmpty() || !$this->futureTickQueue->isEmpty()) {
190+
if (!$this->running || !$this->futureTickQueue->isEmpty()) {
206191
$flags |= EVLOOP_NONBLOCK;
207192
} elseif (!$this->streamEvents && !$this->timerEvents->count()) {
208193
break;

src/LoopInterface.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,6 @@ public function cancelTimer(TimerInterface $timer);
8585
*/
8686
public function isTimerActive(TimerInterface $timer);
8787

88-
/**
89-
* Schedule a callback to be invoked on the next tick of the event loop.
90-
*
91-
* Callbacks are guaranteed to be executed in the order they are enqueued,
92-
* before any timer or stream events.
93-
*
94-
* @param callable $listener The callback to invoke.
95-
*/
96-
public function nextTick(callable $listener);
97-
9888
/**
9989
* Schedule a callback to be invoked on a future tick of the event loop.
10090
*

src/StreamSelectLoop.php

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace React\EventLoop;
44

55
use React\EventLoop\Tick\FutureTickQueue;
6-
use React\EventLoop\Tick\NextTickQueue;
76
use React\EventLoop\Timer\Timer;
87
use React\EventLoop\Timer\TimerInterface;
98
use React\EventLoop\Timer\Timers;
@@ -15,7 +14,6 @@ class StreamSelectLoop implements LoopInterface
1514
{
1615
const MICROSECONDS_PER_SECOND = 1000000;
1716

18-
private $nextTickQueue;
1917
private $futureTickQueue;
2018
private $timers;
2119
private $readStreams = [];
@@ -26,7 +24,6 @@ class StreamSelectLoop implements LoopInterface
2624

2725
public function __construct()
2826
{
29-
$this->nextTickQueue = new NextTickQueue($this);
3027
$this->futureTickQueue = new FutureTickQueue($this);
3128
$this->timers = new Timers();
3229
}
@@ -132,14 +129,6 @@ public function isTimerActive(TimerInterface $timer)
132129
return $this->timers->contains($timer);
133130
}
134131

135-
/**
136-
* {@inheritdoc}
137-
*/
138-
public function nextTick(callable $listener)
139-
{
140-
$this->nextTickQueue->add($listener);
141-
}
142-
143132
/**
144133
* {@inheritdoc}
145134
*/
@@ -153,8 +142,6 @@ public function futureTick(callable $listener)
153142
*/
154143
public function tick()
155144
{
156-
$this->nextTickQueue->tick();
157-
158145
$this->futureTickQueue->tick();
159146

160147
$this->timers->tick();
@@ -170,14 +157,12 @@ public function run()
170157
$this->running = true;
171158

172159
while ($this->running) {
173-
$this->nextTickQueue->tick();
174-
175160
$this->futureTickQueue->tick();
176161

177162
$this->timers->tick();
178163

179-
// Next-tick or future-tick queues have pending callbacks ...
180-
if (!$this->running || !$this->nextTickQueue->isEmpty() || !$this->futureTickQueue->isEmpty()) {
164+
// Future-tick queue has pending callbacks ...
165+
if (!$this->running || !$this->futureTickQueue->isEmpty()) {
181166
$timeout = 0;
182167

183168
// There is a pending timer, only block until it is due ...

src/Tick/NextTickQueue.php

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)