… | |
… | |
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 { |
|
|
161 | $current->{_trace_cb}->(); |
|
|
162 | } |
|
|
163 | |
|
|
164 | # this coroutine is necessary because a coroutine |
160 | # this coroutine is necessary because a coroutine |
165 | # cannot destroy itself. |
161 | # cannot destroy itself. |
166 | my @destroy; |
162 | my @destroy; |
167 | my $manager; |
163 | my $manager; |
168 | |
164 | |
… | |
… | |
312 | |
308 | |
313 | =item terminate [arg...] |
309 | =item terminate [arg...] |
314 | |
310 | |
315 | 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>). |
316 | |
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 | |
317 | =cut |
319 | =cut |
318 | |
320 | |
319 | sub terminate { |
321 | sub terminate { |
320 | $current->cancel (@_); |
322 | $current->cancel (@_); |
|
|
323 | } |
|
|
324 | |
|
|
325 | sub killall { |
|
|
326 | for (Coro::State::list) { |
|
|
327 | $_->cancel |
|
|
328 | if $_ != $current && UNIVERSAL::isa $_, "Coro"; |
|
|
329 | } |
321 | } |
330 | } |
322 | |
331 | |
323 | =back |
332 | =back |
324 | |
333 | |
325 | # dynamic methods |
334 | # dynamic methods |