Skip to content

Commit 5979fc9

Browse files
authored
Merge pull request #30 from clue-labs/no-next-tick
Remove nextTick() and NextTickQueue
2 parents 1bb5263 + 44e059e commit 5979fc9

File tree

7 files changed

+10
-255
lines changed

7 files changed

+10
-255
lines changed

src/ExtEventLoop.php

Lines changed: 1 addition & 14 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
*/
@@ -177,12 +166,10 @@ public function run()
177166
$this->running = true;
178167

179168
while ($this->running) {
180-
$this->nextTickQueue->tick();
181-
182169
$this->futureTickQueue->tick();
183170

184171
$flags = EventBase::LOOP_ONCE;
185-
if (!$this->running || !$this->nextTickQueue->isEmpty() || !$this->futureTickQueue->isEmpty()) {
172+
if (!$this->running || !$this->futureTickQueue->isEmpty()) {
186173
$flags |= EventBase::LOOP_NONBLOCK;
187174
} elseif (!$this->streamEvents && !$this->timerEvents->count()) {
188175
break;

src/LibEvLoop.php

Lines changed: 1 addition & 14 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
*/
@@ -181,12 +170,10 @@ public function run()
181170
$this->running = true;
182171

183172
while ($this->running) {
184-
$this->nextTickQueue->tick();
185-
186173
$this->futureTickQueue->tick();
187174

188175
$flags = EventLoop::RUN_ONCE;
189-
if (!$this->running || !$this->nextTickQueue->isEmpty() || !$this->futureTickQueue->isEmpty()) {
176+
if (!$this->running || !$this->futureTickQueue->isEmpty()) {
190177
$flags |= EventLoop::RUN_NOWAIT;
191178
} elseif (!$this->readEvents && !$this->writeEvents && !$this->timerEvents->count()) {
192179
break;

src/LibEventLoop.php

Lines changed: 1 addition & 14 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
*/
@@ -185,12 +174,10 @@ public function run()
185174
$this->running = true;
186175

187176
while ($this->running) {
188-
$this->nextTickQueue->tick();
189-
190177
$this->futureTickQueue->tick();
191178

192179
$flags = EVLOOP_ONCE;
193-
if (!$this->running || !$this->nextTickQueue->isEmpty() || !$this->futureTickQueue->isEmpty()) {
180+
if (!$this->running || !$this->futureTickQueue->isEmpty()) {
194181
$flags |= EVLOOP_NONBLOCK;
195182
} elseif (!$this->streamEvents && !$this->timerEvents->count()) {
196183
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 & 15 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
*/
@@ -156,14 +145,12 @@ public function run()
156145
$this->running = true;
157146

158147
while ($this->running) {
159-
$this->nextTickQueue->tick();
160-
161148
$this->futureTickQueue->tick();
162149

163150
$this->timers->tick();
164151

165-
// Next-tick or future-tick queues have pending callbacks ...
166-
if (!$this->running || !$this->nextTickQueue->isEmpty() || !$this->futureTickQueue->isEmpty()) {
152+
// Future-tick queue has pending callbacks ...
153+
if (!$this->running || !$this->futureTickQueue->isEmpty()) {
167154
$timeout = 0;
168155

169156
// 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy