File: 20_mutual_cancel.t

package info (click to toggle)
libcoro-perl 6.570-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,144 kB
  • sloc: ansic: 2,560; perl: 2,122; makefile: 14
file content (46 lines) | stat: -rw-r--r-- 811 bytes parent folder | download | duplicates (7)
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
38
39
40
41
42
43
44
45
46
$|=1;
print "1..10\n";

# when two coros cancel each other mutually,
# the slf function currently being executed needs to
# be cleaned up, otherwise the next slf call in the cleanup code
# will simply resume the previous call.
# in addition, mutual cancellation must be specially handled
# as currently, we sometimes cancel coros from another coro
# which must not be interrupted (see slf_init_cancel).

use Coro;

print "ok 1\n";

my ($a, $b);

sub xyz::DESTROY {
   print "ok 7\n";
   $b->cancel;
   print "ok 8\n";
}

$b = async {
   print "ok 3\n";
   cede;
   print "ok 6\n";
   $a->cancel;
   print "not ok 7\n";
};

$a = async {
   print "ok 4\n";
   my $x = bless \my $dummy, "xyz";
   cede;
   print "not ok 5\n";
};

print "ok 2\n";
cede;
print "ok 5\n";
cede;
print "ok 9\n";
cede;
print "ok 10\n";