… | |
… | |
16 | print "data> "; |
16 | print "data> "; |
17 | my $ev = $w->next; my $data = <STDIN>; |
17 | my $ev = $w->next; my $data = <STDIN>; |
18 | } |
18 | } |
19 | } |
19 | } |
20 | |
20 | |
21 | &loop; |
21 | loop; |
22 | |
22 | |
23 | =head1 DESCRIPTION |
23 | =head1 DESCRIPTION |
24 | |
24 | |
25 | This module enables you to create programs using the powerful Event model |
25 | This module enables you to create programs using the powerful Event model |
26 | (and module), while retaining the linear style known from simple or |
26 | (and module), while retaining the linear style known from simple or |
… | |
… | |
43 | no warnings qw(uninitialized); |
43 | no warnings qw(uninitialized); |
44 | |
44 | |
45 | use Carp; |
45 | use Carp; |
46 | |
46 | |
47 | use Coro; |
47 | use Coro; |
48 | use Event qw(unloop); # we are re-exporting this, cooool! |
48 | use Event qw(loop unloop); # we are re-exporting this, cooool! |
49 | |
49 | |
50 | use base 'Exporter'; |
50 | use base 'Exporter'; |
51 | |
51 | |
52 | @EXPORT = qw(loop unloop sweep reschedule); |
52 | @EXPORT = qw(loop unloop sweep reschedule); |
53 | |
53 | |
… | |
… | |
108 | }; |
108 | }; |
109 | *{ $flavour } = $coronew; |
109 | *{ $flavour } = $coronew; |
110 | *{"do_$flavour"} = sub { |
110 | *{"do_$flavour"} = sub { |
111 | unshift @_, Coro::Event::; |
111 | unshift @_, Coro::Event::; |
112 | my $e = (&$coronew)->next; |
112 | my $e = (&$coronew)->next; |
113 | $e->cancel; # $e = $e->w |
113 | $e->cancel; # $e = $e->w->cancel ($e == $e->w!) |
114 | $e; |
114 | $e; |
115 | }; |
115 | }; |
116 | } |
116 | } |
117 | |
117 | |
118 | # double calls to avoid stack-cloning ;() |
118 | # double calls to avoid stack-cloning ;() |
… | |
… | |
156 | |
156 | |
157 | =end comment |
157 | =end comment |
158 | |
158 | |
159 | =cut |
159 | =cut |
160 | |
160 | |
|
|
161 | # no longer do something special - it's done internally now |
|
|
162 | |
161 | sub loop(;$) { |
163 | #sub loop(;$) { |
162 | local $Coro::idle = $Coro::current; |
164 | # #local $Coro::idle = $Coro::current; |
163 | Coro::schedule; # become idle task, which is implicitly ready |
165 | # #Coro::schedule; # become idle task, which is implicitly ready |
164 | &Event::loop; |
166 | # &Event::loop; |
165 | } |
167 | #} |
166 | |
168 | |
167 | =item unloop([$result]) |
169 | =item unloop([$result]) |
168 | |
170 | |
169 | Same as Event::unloop (provided here for your convinience only). |
171 | Same as Event::unloop (provided here for your convinience only). |
170 | |
172 | |