… | |
… | |
366 | |
366 | |
367 | our $idle; # idle handler |
367 | our $idle; # idle handler |
368 | our $main; # main coro |
368 | our $main; # main coro |
369 | our $current; # current coro |
369 | our $current; # current coro |
370 | |
370 | |
371 | our $VERSION = 6.56; |
371 | our $VERSION = 6.57; |
372 | |
372 | |
373 | our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub rouse_cb rouse_wait); |
373 | our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub rouse_cb rouse_wait); |
374 | our %EXPORT_TAGS = ( |
374 | our %EXPORT_TAGS = ( |
375 | prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], |
375 | prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], |
376 | ); |
376 | ); |
… | |
… | |
1085 | |
1085 | |
1086 | Create and return a "rouse callback". That's a code reference that, |
1086 | Create and return a "rouse callback". That's a code reference that, |
1087 | when called, will remember a copy of its arguments and notify the owner |
1087 | when called, will remember a copy of its arguments and notify the owner |
1088 | coro of the callback. |
1088 | coro of the callback. |
1089 | |
1089 | |
1090 | When the callback is invoked multiple times, only the arguments passed on |
1090 | Only the first invocation will store agruments and signal any waiter - |
1091 | the first call will be stored. |
1091 | further calls will effectively be ignored, but it is ok to try. |
1092 | |
1092 | |
1093 | Also see the next function. |
1093 | Also see the next function. |
1094 | |
1094 | |
1095 | =item @args = rouse_wait [$cb] |
1095 | =item @args = rouse_wait [$cb] |
1096 | |
1096 | |
1097 | Wait for the specified rouse callback (or the last one that was created in |
1097 | Wait for the specified rouse callback to be invoked (or if the argument is |
1098 | this coro). |
1098 | missing, use the most recently created callback in the current coro). |
1099 | |
1099 | |
1100 | As soon as the callback is invoked (or when the callback was invoked |
1100 | As soon as the callback is invoked (or when the callback was invoked |
1101 | before C<rouse_wait>), it will return the arguments originally passed to |
1101 | before C<rouse_wait>), it will return the arguments originally passed to |
1102 | the rouse callback. In scalar context, that means you get the I<last> |
1102 | the rouse callback. In scalar context, that means you get the I<last> |
1103 | argument, just as if C<rouse_wait> had a C<return ($a1, $a2, $a3...)> |
1103 | argument, just as if C<rouse_wait> had a C<return ($a1, $a2, $a3...)> |
1104 | statement at the end. |
1104 | statement at the end. |
1105 | |
1105 | |
|
|
1106 | You are only allowed to wait once for a given rouse callback. |
|
|
1107 | |
1106 | See the section B<HOW TO WAIT FOR A CALLBACK> for an actual usage example. |
1108 | See the section B<HOW TO WAIT FOR A CALLBACK> for an actual usage example. |
|
|
1109 | |
|
|
1110 | As of Coro 6.57, you can reliably wait for a rouse callback in a different |
|
|
1111 | thread than from where it was created. |
1107 | |
1112 | |
1108 | =back |
1113 | =back |
1109 | |
1114 | |
1110 | =cut |
1115 | =cut |
1111 | |
1116 | |