1
0
mirror of https://github.com/danog/amp.git synced 2024-11-30 04:29:08 +01:00

Fix #251 - 100% CPU usage in NativeDriver

Also use better bounds for timer - it must not execute before, but may execute a little later (on my system it were up to 7 ms actually)
This commit is contained in:
Bob Weinand 2018-12-11 11:31:37 +01:00
parent 23b8bd2cfe
commit 7075ef7d74
3 changed files with 5 additions and 5 deletions

View File

@ -276,7 +276,7 @@ class NativeDriver extends Driver
continue; continue;
} }
$expiration -= getCurrentTime(); $expiration -= $this->now();
if ($expiration < 0) { if ($expiration < 0) {
return 0; return 0;

View File

@ -1563,8 +1563,8 @@ abstract class DriverTest extends TestCase
$new = $this->loop->now(); $new = $this->loop->now();
// Allow a few milliseconds of inaccuracy. // Allow a few milliseconds of inaccuracy.
$this->assertGreaterThanOrEqual($now - 5, $new); $this->assertGreaterThanOrEqual($now - 1, $new);
$this->assertLessThanOrEqual($now + 5, $new); $this->assertLessThanOrEqual($now + 10, $new);
// Same time should be returned from later call. // Same time should be returned from later call.
$this->assertSame($new, $this->loop->now()); $this->assertSame($new, $this->loop->now());

View File

@ -55,8 +55,8 @@ class LoopTest extends TestCase
$new = Loop::now(); $new = Loop::now();
// Allow a few milliseconds of inaccuracy. // Allow a few milliseconds of inaccuracy.
$this->assertGreaterThanOrEqual($now - 5, $new); $this->assertGreaterThanOrEqual($now - 1, $new);
$this->assertLessThanOrEqual($now + 5, $new); $this->assertLessThanOrEqual($now + 10, $new);
// Same time should be returned from later call. // Same time should be returned from later call.
$this->assertSame($new, Loop::now()); $this->assertSame($new, Loop::now());