… | |
… | |
258 | $coroutine->cancel (arg...) |
258 | $coroutine->cancel (arg...) |
259 | Terminates the given coroutine and makes it return the given |
259 | Terminates the given coroutine and makes it return the given |
260 | arguments as status (default: the empty list). Never returns if the |
260 | arguments as status (default: the empty list). Never returns if the |
261 | coroutine is the current coroutine. |
261 | coroutine is the current coroutine. |
262 | |
262 | |
|
|
263 | $coroutine->throw ([$scalar]) |
|
|
264 | If $throw is specified and defined, it will be thrown as an |
|
|
265 | exception inside the coroutine at the next convenient point in time |
|
|
266 | (usually after it gains control at the next schedule/transfer/cede). |
|
|
267 | Otherwise clears the exception object. |
|
|
268 | |
|
|
269 | The exception object will be thrown "as is" with the specified |
|
|
270 | scalar in $@, i.e. if it is a string, no line number or newline will |
|
|
271 | be appended (unlike with "die"). |
|
|
272 | |
|
|
273 | This can be used as a softer means than "cancel" to ask a coroutine |
|
|
274 | to end itself, although there is no guarantee that the exception |
|
|
275 | will lead to termination, and if the exception isn't caught it might |
|
|
276 | well end the whole program. |
|
|
277 | |
|
|
278 | You might also think of "throw" as being the moral equivalent of |
|
|
279 | "kill"ing a coroutine with a signal (in this case, a scalar). |
|
|
280 | |
263 | $coroutine->join |
281 | $coroutine->join |
264 | Wait until the coroutine terminates and return any values given to |
282 | Wait until the coroutine terminates and return any values given to |
265 | the "terminate" or "cancel" functions. "join" can be called |
283 | the "terminate" or "cancel" functions. "join" can be called |
266 | concurrently from multiple coroutines, and all will be resumed and |
284 | concurrently from multiple coroutines, and all will be resumed and |
267 | given the status return once the $coroutine terminates. |
285 | given the status return once the $coroutine terminates. |
… | |
… | |
303 | this coroutine. This is just a free-form string you can associate |
321 | this coroutine. This is just a free-form string you can associate |
304 | with a coroutine. |
322 | with a coroutine. |
305 | |
323 | |
306 | This method simply sets the "$coroutine->{desc}" member to the given |
324 | This method simply sets the "$coroutine->{desc}" member to the given |
307 | string. You can modify this member directly if you wish. |
325 | string. You can modify this member directly if you wish. |
308 | |
|
|
309 | $coroutine->throw ([$scalar]) |
|
|
310 | If $throw is specified and defined, it will be thrown as an |
|
|
311 | exception inside the coroutine at the next convinient point in time |
|
|
312 | (usually after it gains control at the next schedule/transfer/cede). |
|
|
313 | Otherwise clears the exception object. |
|
|
314 | |
|
|
315 | The exception object will be thrown "as is" with the specified |
|
|
316 | scalar in $@, i.e. if it is a string, no line number or newline will |
|
|
317 | be appended (unlike with "die"). |
|
|
318 | |
|
|
319 | This can be used as a softer means than "cancel" to ask a coroutine |
|
|
320 | to end itself, although there is no guarentee that the exception |
|
|
321 | will lead to termination, and if the exception isn't caught it might |
|
|
322 | well end the whole program. |
|
|
323 | |
326 | |
324 | GLOBAL FUNCTIONS |
327 | GLOBAL FUNCTIONS |
325 | Coro::nready |
328 | Coro::nready |
326 | Returns the number of coroutines that are currently in the ready |
329 | Returns the number of coroutines that are currently in the ready |
327 | state, i.e. that can be switched to by calling "schedule" directory |
330 | state, i.e. that can be switched to by calling "schedule" directory |