… | |
… | |
38 | |
38 | |
39 | use Coro::State; |
39 | use Coro::State; |
40 | |
40 | |
41 | use base Exporter; |
41 | use base Exporter; |
42 | |
42 | |
43 | $VERSION = 0.5; |
43 | $VERSION = 0.51; |
44 | |
44 | |
45 | @EXPORT = qw(async cede schedule terminate current); |
45 | @EXPORT = qw(async cede schedule terminate current); |
46 | %EXPORT_TAGS = ( |
46 | %EXPORT_TAGS = ( |
47 | prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], |
47 | prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], |
48 | ); |
48 | ); |
… | |
… | |
116 | }; |
116 | }; |
117 | |
117 | |
118 | # this coroutine is necessary because a coroutine |
118 | # this coroutine is necessary because a coroutine |
119 | # cannot destroy itself. |
119 | # cannot destroy itself. |
120 | my @destroy; |
120 | my @destroy; |
|
|
121 | my $manager; |
121 | my $manager = new Coro sub { |
122 | $manager = new Coro sub { |
122 | while() { |
123 | while() { |
123 | # by overwriting the state object with the manager we destroy it |
124 | # by overwriting the state object with the manager we destroy it |
124 | # while still being able to schedule this coroutine (in case it has |
125 | # while still being able to schedule this coroutine (in case it has |
125 | # been readied multiple times. this is harmless since the manager |
126 | # been readied multiple times. this is harmless since the manager |
126 | # can be called as many times as neccessary and will always |
127 | # can be called as many times as neccessary and will always |