mirror of
https://github.com/danog/amp.git
synced 2024-11-30 04:29:08 +01:00
Activate watchers at begging of tick instead of end
This commit is contained in:
parent
3e0cd85b67
commit
fbdc611e44
16
lib/Loop.php
16
lib/Loop.php
@ -88,6 +88,13 @@ abstract class Loop extends Driver {
|
||||
* Executes a single tick of the event loop.
|
||||
*/
|
||||
private function tick() {
|
||||
$this->deferQueue = \array_merge($this->deferQueue, $this->nextTickQueue);
|
||||
$this->nextTickQueue = [];
|
||||
|
||||
$queue = $this->enableQueue;
|
||||
$this->enableQueue = [];
|
||||
$this->activate($queue);
|
||||
|
||||
try {
|
||||
foreach ($this->deferQueue as $watcher) {
|
||||
if (!isset($this->deferQueue[$watcher->id])) {
|
||||
@ -117,15 +124,6 @@ abstract class Loop extends Driver {
|
||||
$errorHandler = $this->errorHandler;
|
||||
$errorHandler($exception);
|
||||
}
|
||||
|
||||
foreach ($this->nextTickQueue as $watcher) {
|
||||
$this->deferQueue[$watcher->id] = $watcher;
|
||||
}
|
||||
$this->nextTickQueue = [];
|
||||
|
||||
$queue = $this->enableQueue;
|
||||
$this->enableQueue = [];
|
||||
$this->activate($queue);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user