… | |
… | |
41 | |
41 | |
42 | our $idle; # idle handler |
42 | our $idle; # idle handler |
43 | our $main; # main coroutine |
43 | our $main; # main coroutine |
44 | our $current; # current coroutine |
44 | our $current; # current coroutine |
45 | |
45 | |
46 | our $VERSION = '2.5'; |
46 | our $VERSION = '3.0'; |
47 | |
47 | |
48 | our @EXPORT = qw(async cede schedule terminate current); |
48 | our @EXPORT = qw(async cede schedule terminate current); |
49 | our %EXPORT_TAGS = ( |
49 | our %EXPORT_TAGS = ( |
50 | prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], |
50 | prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], |
51 | ); |
51 | ); |
… | |
… | |
171 | |
171 | |
172 | Create a new asynchronous process and return it's process object |
172 | Create a new asynchronous process and return it's process object |
173 | (usually unused). When the sub returns the new process is automatically |
173 | (usually unused). When the sub returns the new process is automatically |
174 | terminated. |
174 | terminated. |
175 | |
175 | |
|
|
176 | Calling C<exit> in a coroutine will not work correctly, so do not do that. |
|
|
177 | |
176 | When the coroutine dies, the program will exit, just as in the main |
178 | When the coroutine dies, the program will exit, just as in the main |
177 | program. |
179 | program. |
178 | |
180 | |
179 | # create a new coroutine that just prints its arguments |
181 | # create a new coroutine that just prints its arguments |
180 | async { |
182 | async { |
… | |
… | |
229 | |
231 | |
230 | Create a new process and return it. When the sub returns the process |
232 | Create a new process and return it. When the sub returns the process |
231 | automatically terminates as if C<terminate> with the returned values were |
233 | automatically terminates as if C<terminate> with the returned values were |
232 | called. To make the process run you must first put it into the ready queue |
234 | called. To make the process run you must first put it into the ready queue |
233 | by calling the ready method. |
235 | by calling the ready method. |
|
|
236 | |
|
|
237 | Calling C<exit> in a coroutine will not work correctly, so do not do that. |
234 | |
238 | |
235 | =cut |
239 | =cut |
236 | |
240 | |
237 | sub _new_coro { |
241 | sub _new_coro { |
238 | terminate &{+shift}; |
242 | terminate &{+shift}; |