Skip to content

Commit caa18c9

Browse files
committed
Remove now()
Fixes #12.
1 parent 8bcaf94 commit caa18c9

4 files changed

Lines changed: 8 additions & 24 deletions

File tree

composer.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"concurrency",
88
"non-blocking",
99
"event",
10-
"event-loop"
10+
"event-loop",
11+
"scheduler"
1112
],
1213
"license": "MIT",
1314
"authors": [
@@ -40,10 +41,7 @@
4041
"autoload": {
4142
"psr-4": {
4243
"Revolt\\": "src"
43-
},
44-
"files": [
45-
"src/functions.php"
46-
]
44+
}
4745
},
4846
"autoload-dev": {
4947
"psr-4": {

src/EventLoop.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function getHandle(): mixed
5757

5858
protected function now(): float
5959
{
60-
return now();
60+
return (float) \hrtime(true) / 1_000_000_000;
6161
}
6262
};
6363

src/functions.php

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

test/Driver/DriverTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Revolt\EventLoop\Driver;
77
use Revolt\EventLoop\InvalidCallbackError;
88
use Revolt\EventLoop\UnsupportedFeatureException;
9-
use function Revolt\now;
109

1110
if (!\defined("SIGUSR1")) {
1211
\define("SIGUSR1", 30);
@@ -48,10 +47,10 @@ public function testCorrectTimeoutIfBlockingBeforeActivate(): void
4847

4948
$this->start(function (Driver $loop) use (&$start, &$invoked): void {
5049
$loop->defer(function () use ($loop, &$start, &$invoked) {
51-
$start = now();
50+
$start = \microtime(true);
5251

5352
$loop->delay(1, function () use (&$invoked) {
54-
$invoked = now();
53+
$invoked = \microtime(true);
5554
});
5655

5756
\usleep(500000);
@@ -71,12 +70,12 @@ public function testCorrectTimeoutIfBlockingBeforeDelay(): void
7170
$invoked = 0;
7271

7372
$this->start(function (Driver $loop) use (&$start, &$invoked): void {
74-
$start = now();
73+
$start = \microtime(true);
7574

7675
\usleep(500000);
7776

7877
$loop->delay(1, function () use (&$invoked) {
79-
$invoked = now();
78+
$invoked = \microtime(true);
8079
});
8180
});
8281

0 commit comments

Comments
 (0)