… | |
… | |
56 | |
56 | |
57 | =cut |
57 | =cut |
58 | |
58 | |
59 | package Coro; |
59 | package Coro; |
60 | |
60 | |
61 | use strict; |
61 | use strict qw(vars subs); |
62 | no warnings "uninitialized"; |
62 | no warnings "uninitialized"; |
63 | |
63 | |
64 | use Coro::State; |
64 | use Coro::State; |
65 | |
65 | |
66 | use base qw(Coro::State Exporter); |
66 | use base qw(Coro::State Exporter); |
67 | |
67 | |
68 | our $idle; # idle handler |
68 | our $idle; # idle handler |
69 | our $main; # main coroutine |
69 | our $main; # main coroutine |
70 | our $current; # current coroutine |
70 | our $current; # current coroutine |
71 | |
71 | |
72 | our $VERSION = 4.9; |
72 | our $VERSION = 4.912; |
73 | |
73 | |
74 | our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub); |
74 | our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub); |
75 | our %EXPORT_TAGS = ( |
75 | our %EXPORT_TAGS = ( |
76 | prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], |
76 | prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], |
77 | ); |
77 | ); |
… | |
… | |
152 | $self->_destroy |
152 | $self->_destroy |
153 | or return; |
153 | or return; |
154 | |
154 | |
155 | # call all destruction callbacks |
155 | # call all destruction callbacks |
156 | $_->(@{$self->{_status}}) |
156 | $_->(@{$self->{_status}}) |
157 | for @{(delete $self->{_on_destroy}) || []}; |
157 | for @{ delete $self->{_on_destroy} || [] }; |
158 | } |
158 | } |
159 | |
159 | |
160 | # this coroutine is necessary because a coroutine |
160 | # this coroutine is necessary because a coroutine |
161 | # cannot destroy itself. |
161 | # cannot destroy itself. |
162 | my @destroy; |
162 | my @destroy; |