mirror of
https://github.com/danog/amp.git
synced 2024-11-30 04:29:08 +01:00
Addressed drifting repeat alarms
This commit is contained in:
parent
c316405996
commit
d3d034f0d7
12
CHANGELOG.md
Normal file
12
CHANGELOG.md
Normal file
@ -0,0 +1,12 @@
|
||||
#### v0.1.2
|
||||
|
||||
- Addressed execution time drift in repeating native reactor alarms
|
||||
|
||||
#### v0.1.1
|
||||
|
||||
- Addressed infinite recursion in repeating callbacks
|
||||
|
||||
v0.1.0
|
||||
------
|
||||
|
||||
- Initial tagged release
|
@ -110,18 +110,18 @@ class NativeReactor implements Reactor {
|
||||
|
||||
foreach ($this->alarmOrder as $watcherId => $executionCutoff) {
|
||||
if ($executionCutoff <= $now) {
|
||||
$this->doAlarmCallback($watcherId, $now);
|
||||
$this->doAlarmCallback($watcherId);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function doAlarmCallback($watcherId, $now) {
|
||||
private function doAlarmCallback($watcherId) {
|
||||
list($callback, $nextExecution, $interval, $isRepeating) = $this->alarms[$watcherId];
|
||||
|
||||
if ($isRepeating) {
|
||||
$nextExecution = $now + $interval;
|
||||
$nextExecution += $interval;
|
||||
$this->alarms[$watcherId] = [$callback, $nextExecution, $interval, $isRepeating];
|
||||
$this->alarmOrder[$watcherId] = $nextExecution;
|
||||
} else {
|
||||
@ -130,7 +130,7 @@ class NativeReactor implements Reactor {
|
||||
$this->alarmOrder[$watcherId]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$callback($watcherId);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user