… | |
… | |
651 | |
651 | |
652 | $is_suspended = $coro->is_suspended |
652 | $is_suspended = $coro->is_suspended |
653 | Returns true iff this Coro object has been suspended. Suspended |
653 | Returns true iff this Coro object has been suspended. Suspended |
654 | Coros will not ever be scheduled. |
654 | Coros will not ever be scheduled. |
655 | |
655 | |
656 | $coro->cancel (arg...) |
656 | $coro->cancel ($arg...) |
657 | Terminates the given Coro thread and makes it return the given |
657 | Terminate the given Coro thread and make it return the given |
658 | arguments as status (default: an empty list). Never returns if the |
658 | arguments as status (default: an empty list). Never returns if the |
659 | Coro is the current Coro. |
659 | Coro is the current Coro. |
660 | |
660 | |
661 | This is a rather brutal way to free a coro, with some limitations - |
661 | This is a rather brutal way to free a coro, with some limitations - |
662 | if the thread is inside a C callback that doesn't expect to be |
662 | if the thread is inside a C callback that doesn't expect to be |
… | |
… | |
697 | context and can block if they wish. The downside is that there is no |
697 | context and can block if they wish. The downside is that there is no |
698 | guarantee that the thread can be cancelled when you call this |
698 | guarantee that the thread can be cancelled when you call this |
699 | method, and therefore, it might fail. It is also considerably slower |
699 | method, and therefore, it might fail. It is also considerably slower |
700 | than "cancel" or "terminate". |
700 | than "cancel" or "terminate". |
701 | |
701 | |
702 | A thread is in a safe-cancellable state if it either hasn't been run |
702 | A thread is in a safe-cancellable state if it either has never been |
|
|
703 | run yet, has already been canceled/terminated or otherwise |
703 | yet, or it has no C context attached and is inside an SLF function. |
704 | destroyed, or has no C context attached and is inside an SLF |
|
|
705 | function. |
704 | |
706 | |
|
|
707 | The first two states are trivial - a thread that hasnot started or |
|
|
708 | has already finished is safe to cancel. |
|
|
709 | |
705 | The latter two basically mean that the thread isn't currently inside |
710 | The last state basically means that the thread isn't currently |
706 | a perl callback called from some C function (usually via some XS |
711 | inside a perl callback called from some C function (usually via some |
707 | modules) and isn't currently executing inside some C function itself |
712 | XS modules) and isn't currently executing inside some C function |
708 | (via Coro's XS API). |
713 | itself (via Coro's XS API). |
709 | |
714 | |
710 | This call returns true when it could cancel the thread, or croaks |
715 | This call returns true when it could cancel the thread, or croaks |
711 | with an error otherwise (i.e. it either returns true or doesn't |
716 | with an error otherwise (i.e. it either returns true or doesn't |
712 | return at all). |
717 | return at all). |
713 | |
718 | |