… | |
… | |
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 | |
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. |
|
|
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. |
313 | |
337 | |