… | |
… | |
788 | |
788 | |
789 | =item $coro->join |
789 | =item $coro->join |
790 | |
790 | |
791 | Wait until the coro terminates and return any values given to the |
791 | Wait until the coro terminates and return any values given to the |
792 | C<terminate> or C<cancel> functions. C<join> can be called concurrently |
792 | C<terminate> or C<cancel> functions. C<join> can be called concurrently |
793 | from multiple coro, and all will be resumed and given the status |
793 | from multiple threads, and all will be resumed and given the status |
794 | return once the C<$coro> terminates. |
794 | return once the C<$coro> terminates. |
795 | |
795 | |
796 | =cut |
796 | =cut |
797 | |
797 | |
798 | sub join { |
798 | sub join { |
… | |
… | |
813 | } |
813 | } |
814 | |
814 | |
815 | =item $coro->on_destroy (\&cb) |
815 | =item $coro->on_destroy (\&cb) |
816 | |
816 | |
817 | Registers a callback that is called when this coro thread gets destroyed, |
817 | Registers a callback that is called when this coro thread gets destroyed, |
818 | but before it is joined. The callback gets passed the terminate arguments, |
818 | that is, after it's resources have been freed but before it is joined. The |
|
|
819 | callback gets passed the terminate/cancel arguments, if any, and I<must |
819 | if any, and I<must not> die, under any circumstances. |
820 | not> die, under any circumstances. |
820 | |
821 | |
821 | There can be any number of C<on_destroy> callbacks per coro. |
822 | There can be any number of C<on_destroy> callbacks per coro, and there is |
|
|
823 | no way currently to remove a callback once added. |
822 | |
824 | |
823 | =cut |
825 | =cut |
824 | |
826 | |
825 | sub on_destroy { |
827 | sub on_destroy { |
826 | my ($self, $cb) = @_; |
828 | my ($self, $cb) = @_; |