1 | $|=1; |
1 | $|=1; |
2 | print "1..6\n"; |
2 | print "1..8\n"; |
3 | |
3 | |
4 | use Coro; |
4 | use Coro; |
|
|
5 | use Coro::Signal; |
5 | use Coro::Timer; |
6 | use Coro::Timer; |
6 | |
7 | |
7 | print "ok 1\n"; |
8 | print "ok 1\n"; |
8 | |
9 | |
|
|
10 | my $signal = new Coro::Signal; |
|
|
11 | |
9 | new Coro::Timer after => 0, cb => sub { |
12 | new Coro::Timer after => 0, cb => sub { |
10 | print "ok 2\n"; |
13 | print "ok 2\n"; |
11 | }; |
14 | }; |
12 | new Coro::Timer after => 1, cb => sub { |
15 | new Coro::Timer at => time + 1, cb => sub { |
13 | print "ok 4\n"; |
16 | print "ok 4\n"; |
|
|
17 | }; |
|
|
18 | new Coro::Timer after => 2, cb => sub { |
|
|
19 | $signal->send; |
14 | }; |
20 | }; |
15 | new Coro::Timer after => 0, cb => sub { |
21 | new Coro::Timer after => 0, cb => sub { |
16 | print "ok 3\n"; |
22 | print "ok 3\n"; |
17 | }; |
23 | }; |
18 | (new Coro::Timer after => 0, cb => sub { |
24 | (new Coro::Timer after => 0, cb => sub { |
19 | print "not ok 4\n"; |
25 | print "not ok 4\n"; |
20 | })->cancel; |
26 | })->cancel; |
21 | new Coro::Timer at => time + 2, cb => sub { |
27 | new Coro::Timer at => time + 3, cb => sub { |
22 | print "ok 5\n"; |
28 | print "ok 7\n"; |
23 | $Coro::main->ready; |
29 | $Coro::main->ready; |
24 | }; |
30 | }; |
25 | |
31 | |
|
|
32 | print $signal->timed_wait(1) ? "not ok" : "ok", " 5\n"; |
|
|
33 | print $signal->timed_wait(1) ? "ok" : "not ok", " 6\n"; |
26 | schedule; |
34 | schedule; |
27 | print "ok 6\n"; |
35 | print "ok 8\n"; |