--- cvsroot/Coro/Coro.pm 2009/10/01 23:16:27 1.268 +++ cvsroot/Coro/Coro.pm 2009/10/02 19:55:59 1.271 @@ -83,9 +83,9 @@ our $main; # main coro our $current; # current coro -our $VERSION = 5.17; +our $VERSION = 5.2; -our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub); +our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub rouse_cb rouse_wait); our %EXPORT_TAGS = ( prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], ); @@ -126,38 +126,24 @@ usually better to rely on L or L, as this is pretty low-level functionality. -This variable stores either a Coro object or a callback. +This variable stores a Coro object that is put into the ready queue when +there are no other ready threads (without invoking any ready hooks). -If it is a callback, the it is called whenever the scheduler finds no -ready coros to run. The default implementation prints "FATAL: -deadlock detected" and exits, because the program has no other way to -continue. - -If it is a coro object, then this object will be readied (without -invoking any ready hooks, however) when the scheduler finds no other ready -coros to run. +The default implementation dies with "FATAL: deadlock detected.", followed +by a thread listing, because the program has no other way to continue. This hook is overwritten by modules such as C and C to wait on an external event that hopefully wake up a coro so the scheduler can run it. -Note that the callback I, under any circumstances, block -the current coro. Normally, this is achieved by having an "idle -coro" that calls the event loop and then blocks again, and then -readying that coro in the idle handler, or by simply placing the idle -coro in this variable. - -See L or L for examples of using this -technique. - -Please note that if your callback recursively invokes perl (e.g. for event -handlers), then it must be prepared to be called recursively itself. +See L or L for examples of using this technique. =cut -$idle = sub { - warn "oi\n";#d# - Carp::confess ("FATAL: deadlock detected"); +$idle = new Coro sub { + require Coro::Debug; + die "FATAL: deadlock detected.\n" + . Coro::Debug::ps_listing (); }; # this coro is necessary because a coro @@ -275,7 +261,7 @@ Calls the scheduler. The scheduler will find the next coro that is to be run from the ready queue and switches to it. The next coro to be run is simply the one with the highest priority that is longest -in its ready queue. If there is no coro ready, it will clal the +in its ready queue. If there is no coro ready, it will call the C<$Coro::idle> hook. Please note that the current coro will I be put into the ready @@ -731,7 +717,7 @@ } } -=item $cb = Coro::rouse_cb +=item $cb = rouse_cb Create and return a "rouse callback". That's a code reference that, when called, will remember a copy of its arguments and notify the owner @@ -739,7 +725,7 @@ See the next function. -=item @args = Coro::rouse_wait [$cb] +=item @args = rouse_wait [$cb] Wait for the specified rouse callback (or the last one that was created in this coro).