… | |
… | |
782 | =item $is_suspended = $coro->is_suspended |
782 | =item $is_suspended = $coro->is_suspended |
783 | |
783 | |
784 | Returns true iff this Coro object has been suspended. Suspended Coros will |
784 | Returns true iff this Coro object has been suspended. Suspended Coros will |
785 | not ever be scheduled. |
785 | not ever be scheduled. |
786 | |
786 | |
787 | =item $coro->cancel (arg...) |
787 | =item $coro->cancel ($arg...) |
788 | |
788 | |
789 | Terminates the given Coro thread and makes it return the given arguments as |
789 | Terminate the given Coro thread and make it return the given arguments as |
790 | status (default: an empty list). Never returns if the Coro is the |
790 | status (default: an empty list). Never returns if the Coro is the |
791 | current Coro. |
791 | current Coro. |
792 | |
792 | |
793 | This is a rather brutal way to free a coro, with some limitations - if |
793 | This is a rather brutal way to free a coro, with some limitations - if |
794 | the thread is inside a C callback that doesn't expect to be canceled, |
794 | the thread is inside a C callback that doesn't expect to be canceled, |
… | |
… | |
830 | context and can block if they wish. The downside is that there is no |
830 | context and can block if they wish. The downside is that there is no |
831 | guarantee that the thread can be cancelled when you call this method, and |
831 | guarantee that the thread can be cancelled when you call this method, and |
832 | therefore, it might fail. It is also considerably slower than C<cancel> or |
832 | therefore, it might fail. It is also considerably slower than C<cancel> or |
833 | C<terminate>. |
833 | C<terminate>. |
834 | |
834 | |
835 | A thread is in a safe-cancellable state if it either hasn't been run yet, |
835 | A thread is in a safe-cancellable state if it either has never been run |
|
|
836 | yet, has already been canceled/terminated or otherwise destroyed, or has |
836 | or it has no C context attached and is inside an SLF function. |
837 | no C context attached and is inside an SLF function. |
837 | |
838 | |
|
|
839 | The first two states are trivial - a thread that hasnot started or has |
|
|
840 | already finished is safe to cancel. |
|
|
841 | |
838 | The latter two basically mean that the thread isn't currently inside a |
842 | The last state basically means that the thread isn't currently inside a |
839 | perl callback called from some C function (usually via some XS modules) |
843 | perl callback called from some C function (usually via some XS modules) |
840 | and isn't currently executing inside some C function itself (via Coro's XS |
844 | and isn't currently executing inside some C function itself (via Coro's XS |
841 | API). |
845 | API). |
842 | |
846 | |
843 | This call returns true when it could cancel the thread, or croaks with an |
847 | This call returns true when it could cancel the thread, or croaks with an |