… | |
… | |
427 | |
427 | |
428 | This ensures that the scheduler will resume this coro automatically |
428 | This ensures that the scheduler will resume this coro automatically |
429 | once all the coro of higher priority and all coro of the same |
429 | once all the coro of higher priority and all coro of the same |
430 | priority that were put into the ready queue earlier have been resumed. |
430 | priority that were put into the ready queue earlier have been resumed. |
431 | |
431 | |
|
|
432 | =item $coro->suspend |
|
|
433 | |
|
|
434 | Suspends the specified coro. A suspended coro works just like any other |
|
|
435 | coro, except that the scheduler will not select a suspended coro for |
|
|
436 | execution. |
|
|
437 | |
|
|
438 | Suspending a coro can be useful when you want to keep the coro from |
|
|
439 | running, but you don't want to destroy it, or when you want to temporarily |
|
|
440 | freeze a coro (e.g. for debugging) to resume it later. |
|
|
441 | |
|
|
442 | A scenario for the former would be to suspend all (other) coros after a |
|
|
443 | fork and keep them alive, so their destructors aren't called, but new |
|
|
444 | coros can be created. |
|
|
445 | |
|
|
446 | =item $coro->resume |
|
|
447 | |
|
|
448 | If the specified coro was suspended, it will be resumed. Note that when |
|
|
449 | the coro was in the ready queue when it was suspended, it might have been |
|
|
450 | unreadied by the scheduler, so an activation might have been lost. |
|
|
451 | |
|
|
452 | To avoid this, it is best to put a suspended coro into the ready queue |
|
|
453 | unconditionally, as every synchronisation mechanism must protect itself |
|
|
454 | against spurious wakeups, and the one in the Coro family certainly do |
|
|
455 | that. |
|
|
456 | |
432 | =item $is_ready = $coro->is_ready |
457 | =item $is_ready = $coro->is_ready |
433 | |
458 | |
434 | Returns true iff the Coro object is in the ready queue. Unless the Coro |
459 | Returns true iff the Coro object is in the ready queue. Unless the Coro |
435 | object gets destroyed, it will eventually be scheduled by the scheduler. |
460 | object gets destroyed, it will eventually be scheduled by the scheduler. |
436 | |
461 | |