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

Comparing cvsroot/Coro/README (file contents):
Revision 1.21 by root, Mon Dec 15 20:52:04 2008 UTC vs.
Revision 1.23 by root, Fri May 29 07:01:18 2009 UTC

247 These functions are best understood by an example: The following 247 These functions are best understood by an example: The following
248 function will change the current timezone to 248 function will change the current timezone to
249 "Antarctica/South_Pole", which requires a call to "tzset", but by 249 "Antarctica/South_Pole", which requires a call to "tzset", but by
250 using "on_enter" and "on_leave", which remember/change the current 250 using "on_enter" and "on_leave", which remember/change the current
251 timezone and restore the previous value, respectively, the timezone 251 timezone and restore the previous value, respectively, the timezone
252 is only changes for the coro that installed those handlers. 252 is only changed for the coro that installed those handlers.
253 253
254 use POSIX qw(tzset); 254 use POSIX qw(tzset);
255 255
256 async { 256 async {
257 my $old_tz; # store outside TZ value here 257 my $old_tz; # store outside TZ value here
303 303
304 This ensures that the scheduler will resume this coro automatically 304 This ensures that the scheduler will resume this coro automatically
305 once all the coro of higher priority and all coro of the same 305 once all the coro of higher priority and all coro of the same
306 priority that were put into the ready queue earlier have been 306 priority that were put into the ready queue earlier have been
307 resumed. 307 resumed.
308
309 $coro->suspend
310 Suspends the specified coro. A suspended coro works just like any
311 other coro, except that the scheduler will not select a suspended
312 coro for execution.
313
314 Suspending a coro can be useful when you want to keep the coro from
315 running, but you don't want to destroy it, or when you want to
316 temporarily freeze a coro (e.g. for debugging) to resume it later.
317
318 A scenario for the former would be to suspend all (other) coros
319 after a fork and keep them alive, so their destructors aren't
320 called, but new coros can be created.
321
322 $coro->resume
323 If the specified coro was suspended, it will be resumed. Note that
324 when the coro was in the ready queue when it was suspended, it might
325 have been unreadied by the scheduler, so an activation might have
326 been lost.
327
328 To avoid this, it is best to put a suspended coro into the ready
329 queue unconditionally, as every synchronisation mechanism must
330 protect itself against spurious wakeups, and the one in the Coro
331 family certainly do that.
308 332
309 $is_ready = $coro->is_ready 333 $is_ready = $coro->is_ready
310 Returns true iff the Coro object is in the ready queue. Unless the 334 Returns true iff the Coro object is in the ready queue. Unless the
311 Coro object gets destroyed, it will eventually be scheduled by the 335 Coro object gets destroyed, it will eventually be scheduled by the
312 scheduler. 336 scheduler.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines