… | |
… | |
66 | package Coro; |
66 | package Coro; |
67 | |
67 | |
68 | use strict qw(vars subs); |
68 | use strict qw(vars subs); |
69 | no warnings "uninitialized"; |
69 | no warnings "uninitialized"; |
70 | |
70 | |
|
|
71 | use Guard (); |
|
|
72 | |
71 | use Coro::State; |
73 | use Coro::State; |
72 | |
74 | |
73 | use base qw(Coro::State Exporter); |
75 | use base qw(Coro::State Exporter); |
74 | |
76 | |
75 | our $idle; # idle handler |
77 | our $idle; # idle handler |
76 | our $main; # main coroutine |
78 | our $main; # main coroutine |
77 | our $current; # current coroutine |
79 | our $current; # current coroutine |
78 | |
80 | |
79 | our $VERSION = 5.12; |
81 | our $VERSION = 5.13; |
80 | |
82 | |
81 | our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub); |
83 | our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub); |
82 | our %EXPORT_TAGS = ( |
84 | our %EXPORT_TAGS = ( |
83 | prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], |
85 | prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], |
84 | ); |
86 | ); |
… | |
… | |
315 | Terminates the current coroutine with the given status values (see L<cancel>). |
317 | Terminates the current coroutine with the given status values (see L<cancel>). |
316 | |
318 | |
317 | =item killall |
319 | =item killall |
318 | |
320 | |
319 | Kills/terminates/cancels all coroutines except the currently running |
321 | Kills/terminates/cancels all coroutines except the currently running |
320 | one. This is useful after a fork, either in the child or the parent, as |
322 | one. This can be useful after a fork, either in the child or the parent, |
321 | usually only one of them should inherit the running coroutines. |
323 | as usually only one of them should inherit the running coroutines. |
|
|
324 | |
|
|
325 | Note that in the implementation, destructors run as normal, making this |
|
|
326 | function not so useful after a fork. Future versions of this function |
|
|
327 | might try to free resources without running any code. |
322 | |
328 | |
323 | Note that while this will try to free some of the main programs resources, |
329 | Note that while this will try to free some of the main programs resources, |
324 | you cannot free all of them, so if a coroutine that is not the main |
330 | you cannot free all of them, so if a coroutine that is not the main |
325 | program calls this function, there will be some one-time resource leak. |
331 | program calls this function, there will be some one-time resource leak. |
326 | |
332 | |