… | |
… | |
155 | # call all destruction callbacks |
155 | # call all destruction callbacks |
156 | $_->(@{$self->{status}}) |
156 | $_->(@{$self->{status}}) |
157 | for @{(delete $self->{destroy_cb}) || []}; |
157 | for @{(delete $self->{destroy_cb}) || []}; |
158 | } |
158 | } |
159 | |
159 | |
160 | sub _do_trace_sub { |
|
|
161 | &{$current->{_trace_sub_cb}} |
|
|
162 | } |
|
|
163 | |
|
|
164 | sub _do_trace_line { |
|
|
165 | &{$current->{_trace_line_cb}} |
|
|
166 | } |
|
|
167 | |
|
|
168 | # this coroutine is necessary because a coroutine |
160 | # this coroutine is necessary because a coroutine |
169 | # cannot destroy itself. |
161 | # cannot destroy itself. |
170 | my @destroy; |
162 | my @destroy; |
171 | my $manager; |
163 | my $manager; |
172 | |
164 | |
… | |
… | |
316 | |
308 | |
317 | =item terminate [arg...] |
309 | =item terminate [arg...] |
318 | |
310 | |
319 | Terminates the current coroutine with the given status values (see L<cancel>). |
311 | Terminates the current coroutine with the given status values (see L<cancel>). |
320 | |
312 | |
|
|
313 | =item killall |
|
|
314 | |
|
|
315 | Kills/terminates/cancels all coroutines except the currently running |
|
|
316 | one. This is useful after a fork, either in the child or the parent, as |
|
|
317 | usually only one of them should inherit the running coroutines. |
|
|
318 | |
321 | =cut |
319 | =cut |
322 | |
320 | |
323 | sub terminate { |
321 | sub terminate { |
324 | $current->cancel (@_); |
322 | $current->cancel (@_); |
|
|
323 | } |
|
|
324 | |
|
|
325 | sub killall { |
|
|
326 | for (Coro::State::list) { |
|
|
327 | $_->cancel |
|
|
328 | if $_ != $current && UNIVERSAL::isa $_, "Coro"; |
|
|
329 | } |
325 | } |
330 | } |
326 | |
331 | |
327 | =back |
332 | =back |
328 | |
333 | |
329 | # dynamic methods |
334 | # dynamic methods |