… | |
… | |
32 | |
32 | |
33 | =cut |
33 | =cut |
34 | |
34 | |
35 | package Coro; |
35 | package Coro; |
36 | |
36 | |
|
|
37 | no warnings qw(uninitialized); |
|
|
38 | |
37 | use Coro::State; |
39 | use Coro::State; |
38 | |
40 | |
39 | use base Exporter; |
41 | use base Exporter; |
40 | |
42 | |
41 | $VERSION = 0.45; |
43 | $VERSION = 0.5; |
42 | |
44 | |
43 | @EXPORT = qw(async cede schedule terminate current); |
45 | @EXPORT = qw(async cede schedule terminate current); |
44 | %EXPORT_TAGS = ( |
46 | %EXPORT_TAGS = ( |
45 | 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)], |
46 | ); |
48 | ); |
… | |
… | |
229 | =cut |
231 | =cut |
230 | |
232 | |
231 | sub cancel { |
233 | sub cancel { |
232 | push @destroy, $_[0]; |
234 | push @destroy, $_[0]; |
233 | $manager->ready; |
235 | $manager->ready; |
|
|
236 | &schedule if $current == $_[0]; |
234 | } |
237 | } |
235 | |
238 | |
236 | =item $oldprio = $process->prio($newprio) |
239 | =item $oldprio = $process->prio($newprio) |
237 | |
240 | |
238 | Sets the priority of the process. Higher priority processes get run before |
241 | Sets the priority of the process. Higher priority processes get run before |
… | |
… | |
279 | |
282 | |
280 | 1; |
283 | 1; |
281 | |
284 | |
282 | =head1 BUGS/LIMITATIONS |
285 | =head1 BUGS/LIMITATIONS |
283 | |
286 | |
284 | - could be faster, especially when the core would introduce special |
287 | - you must make very sure that no coro is still active on global destruction. |
285 | support for coroutines (like it does for threads). |
288 | very bad things might happen otherwise (usually segfaults). |
286 | - there is still a memleak on coroutine termination that I could not |
|
|
287 | identify. Could be as small as a single SV. |
|
|
288 | - this module is not well-tested. |
|
|
289 | - if variables or arguments "disappear" (become undef) or become |
|
|
290 | corrupted please contact the author so he cen iron out the |
|
|
291 | remaining bugs. |
|
|
292 | - this module is not thread-safe. You must only ever use this module from |
289 | - this module is not thread-safe. You must only ever use this module from |
293 | the same thread (this requirement might be loosened in the future to |
290 | the same thread (this requirement might be loosened in the future to |
294 | allow per-thread schedulers, but Coro::State does not yet allow this). |
291 | allow per-thread schedulers, but Coro::State does not yet allow this). |
295 | |
292 | |
296 | =head1 SEE ALSO |
293 | =head1 SEE ALSO |