… | |
… | |
90 | my ($port, $threadcb) = @_; |
90 | my ($port, $threadcb) = @_; |
91 | |
91 | |
92 | my $coro = async_pool { |
92 | my $coro = async_pool { |
93 | # we do it inside the thread, because this hopefully gives us the correct $SELF, |
93 | # we do it inside the thread, because this hopefully gives us the correct $SELF, |
94 | # as $SELF should not be localised when threads are switched. |
94 | # as $SELF should not be localised when threads are switched. |
95 | $coro->swap_sv (\$SELF, \$port); |
95 | $Coro::current->swap_sv (\$SELF, \$port); |
96 | eval { $threadcb->() }; |
96 | eval { $threadcb->() }; |
97 | kil $SELF, die => $@ if $@; |
97 | kil $SELF, die => $@ if $@; |
98 | }; |
98 | }; |
99 | |
99 | |
100 | # killing the port cancels the coro |
100 | # killing the port cancels the coro |