-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevents.php
More file actions
37 lines (29 loc) · 831 Bytes
/
events.php
File metadata and controls
37 lines (29 loc) · 831 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
27
28
29
30
31
32
33
34
35
36
37
<?php
use Amp\Delayed;
use PHPinnacle\Ensign\DispatcherBuilder;
require __DIR__ . '/../vendor/autoload.php';
Amp\Loop::run(function () {
$builder = new DispatcherBuilder;
$builder
->register('print', function ($num) {
for ($i = 0; $i < $num; $i++) {
echo '-';
yield new Delayed(100);
}
})
->register('print', function ($num) {
for ($i = 0; $i < $num; $i++) {
echo '+';
yield new Delayed(100);
}
})
->register('print', function ($num) {
for ($i = 0; $i < $num; $i++) {
echo '*';
yield new Delayed(50);
}
})
;
$dispatcher = $builder->build();
yield $dispatcher->dispatch('print', 10);
});