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

Comparing Coro/Coro.pm (file contents):
Revision 1.112 by root, Sat Jan 20 19:52:15 2007 UTC vs.
Revision 1.119 by root, Wed Mar 28 14:24:17 2007 UTC

50 50
51our $idle; # idle handler 51our $idle; # idle handler
52our $main; # main coroutine 52our $main; # main coroutine
53our $current; # current coroutine 53our $current; # current coroutine
54 54
55our $VERSION = '3.41'; 55our $VERSION = '3.55';
56 56
57our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub); 57our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub);
58our %EXPORT_TAGS = ( 58our %EXPORT_TAGS = (
59 prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], 59 prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)],
60); 60);
242 warn $@ if $@; 242 warn $@ if $@;
243 243
244 last if @pool >= $POOL_SIZE; 244 last if @pool >= $POOL_SIZE;
245 push @pool, $current; 245 push @pool, $current;
246 246
247 $current->save (Coro::State::SAVE_DEF);
247 $current->prio (0); 248 $current->prio (0);
248 schedule; 249 schedule;
249 } 250 }
250} 251}
251 252
465and C<schedule> would cause a deadlock unless there is an idle handler 466and C<schedule> would cause a deadlock unless there is an idle handler
466that wakes up some coroutines. 467that wakes up some coroutines.
467 468
468=item my $guard = Coro::guard { ... } 469=item my $guard = Coro::guard { ... }
469 470
470This creates and returns a guard object. Nothing happens until the objetc 471This creates and returns a guard object. Nothing happens until the object
471gets destroyed, in which case the codeblock given as argument will be 472gets destroyed, in which case the codeblock given as argument will be
472executed. This is useful to free locks or other resources in case of a 473executed. This is useful to free locks or other resources in case of a
473runtime error or when the coroutine gets canceled, as in both cases the 474runtime error or when the coroutine gets canceled, as in both cases the
474guard block will be executed. The guard object supports only one method, 475guard block will be executed. The guard object supports only one method,
475C<< ->cancel >>, which will keep the codeblock from being executed. 476C<< ->cancel >>, which will keep the codeblock from being executed.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines