… | |
… | |
74 | |
74 | |
75 | our $idle; # idle handler |
75 | our $idle; # idle handler |
76 | our $main; # main coroutine |
76 | our $main; # main coroutine |
77 | our $current; # current coroutine |
77 | our $current; # current coroutine |
78 | |
78 | |
79 | our $VERSION = "5.0"; |
79 | our $VERSION = 5.11; |
80 | |
80 | |
81 | our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub); |
81 | our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub); |
82 | our %EXPORT_TAGS = ( |
82 | our %EXPORT_TAGS = ( |
83 | prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], |
83 | prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], |
84 | ); |
84 | ); |
… | |
… | |
175 | |
175 | |
176 | =over 4 |
176 | =over 4 |
177 | |
177 | |
178 | =item async { ... } [@args...] |
178 | =item async { ... } [@args...] |
179 | |
179 | |
180 | Create a new coroutine and return it's coroutine object (usually |
180 | Create a new coroutine and return its coroutine object (usually |
181 | unused). The coroutine will be put into the ready queue, so |
181 | unused). The coroutine will be put into the ready queue, so |
182 | it will start running automatically on the next scheduler run. |
182 | it will start running automatically on the next scheduler run. |
183 | |
183 | |
184 | The first argument is a codeblock/closure that should be executed in the |
184 | The first argument is a codeblock/closure that should be executed in the |
185 | coroutine. When it returns argument returns the coroutine is automatically |
185 | coroutine. When it returns argument returns the coroutine is automatically |
… | |
… | |
681 | |
681 | |
682 | Coro offers two functions specifically designed to make this easy, |
682 | Coro offers two functions specifically designed to make this easy, |
683 | C<Coro::rouse_cb> and C<Coro::rouse_wait>. |
683 | C<Coro::rouse_cb> and C<Coro::rouse_wait>. |
684 | |
684 | |
685 | The first function, C<rouse_cb>, generates and returns a callback that, |
685 | The first function, C<rouse_cb>, generates and returns a callback that, |
686 | when invoked, will save it's arguments and notify the coroutine that |
686 | when invoked, will save its arguments and notify the coroutine that |
687 | created the callback. |
687 | created the callback. |
688 | |
688 | |
689 | The second function, C<rouse_wait>, waits for the callback to be called |
689 | The second function, C<rouse_wait>, waits for the callback to be called |
690 | (by calling C<schedule> to go to sleep) and returns the arguments |
690 | (by calling C<schedule> to go to sleep) and returns the arguments |
691 | originally passed to the callback. |
691 | originally passed to the callback. |