-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathticking_future.php
More file actions
26 lines (19 loc) · 650 Bytes
/
ticking_future.php
File metadata and controls
26 lines (19 loc) · 650 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
declare(strict_types=1);
use function WyriHaximus\React\tickingFuturePromise;
require dirname(__DIR__) . '/vendor/autoload.php';
const WAIT_COUNT = 307200;
$start = time();
$count = 0;
echo 'Wait ' . WAIT_COUNT . ' ticks before resolving:', PHP_EOL;
tickingFuturePromise(static function ($waitCount) use (&$count, $start) {
echo '.';
if (++$count === $waitCount) {
return $start;
}
return false;
}, WAIT_COUNT)->then(static function ($start): void {
echo PHP_EOL, 'That took ' . (time() - $start) . ' seconds.', PHP_EOL;
}, static function ($exception): void {
echo $exception->getMessage(), PHP_EOL;
});