ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro.pm
(Generate patch)

Comparing Coro/Coro.pm (file contents):
Revision 1.355 by root, Thu Feb 20 18:42:14 2020 UTC vs.
Revision 1.356 by root, Mon Mar 16 11:12:52 2020 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines