… | |
… | |
436 | } |
436 | } |
437 | |
437 | |
438 | =item $coroutine->throw ([$scalar]) |
438 | =item $coroutine->throw ([$scalar]) |
439 | |
439 | |
440 | If C<$throw> is specified and defined, it will be thrown as an exception |
440 | If C<$throw> is specified and defined, it will be thrown as an exception |
441 | inside the coroutine at the next convenient point in time (usually after |
441 | inside the coroutine at the next convenient point in time. Otherwise |
442 | it gains control at the next schedule/transfer/cede). Otherwise clears the |
|
|
443 | exception object. |
442 | clears the exception object. |
|
|
443 | |
|
|
444 | Coro will check for the exception each time a schedule-like-function |
|
|
445 | returns, i.e. after each C<schedule>, C<cede>, C<< Coro::Semaphore->down |
|
|
446 | >>, C<< Coro::Handle->readable >> and so on. Note that this means that |
|
|
447 | when a coroutine is acquiring a lock, it might only throw after it has |
|
|
448 | sucessfully acquired it. |
444 | |
449 | |
445 | The exception object will be thrown "as is" with the specified scalar in |
450 | The exception object will be thrown "as is" with the specified scalar in |
446 | C<$@>, i.e. if it is a string, no line number or newline will be appended |
451 | C<$@>, i.e. if it is a string, no line number or newline will be appended |
447 | (unlike with C<die>). |
452 | (unlike with C<die>). |
448 | |
453 | |
… | |
… | |
680 | =item coroutine switching not signal safe |
685 | =item coroutine switching not signal safe |
681 | |
686 | |
682 | You must not switch to another coroutine from within a signal handler |
687 | You must not switch to another coroutine from within a signal handler |
683 | (only relevant with %SIG - most event libraries provide safe signals). |
688 | (only relevant with %SIG - most event libraries provide safe signals). |
684 | |
689 | |
685 | That means you I<MUST NOT> call any fucntion that might "block" the |
690 | That means you I<MUST NOT> call any function that might "block" the |
686 | current coroutine - C<cede>, C<schedule> C<< Coro::Semaphore->down >> or |
691 | current coroutine - C<cede>, C<schedule> C<< Coro::Semaphore->down >> or |
687 | anything that calls those. Everything else, including calling C<ready>, |
692 | anything that calls those. Everything else, including calling C<ready>, |
688 | works. |
693 | works. |
689 | |
694 | |
690 | =back |
695 | =back |