Deadlock when cancelling coros
schmorp at schmorp.de
Fri May 6 21:53:13 CEST 2011
> On Fri, May 06, 2011 at 12:58:21PM -0400, Laurent <laurent.aml at gmail.com> wrote:
> > So basically, you suggest to not use AnyEvent or coro-aware blocking
> > calls (condvar/sleep/unblocked IO/...) within destructors/guards when
> > we intend to use coro cancellation.
> Yes, basically. You *can* create a new coro to handle the waiting though.
You *could* also try throwing an exception instead of canceling -
$coro->throw ("terminate, damnit").
That is much "softer" then a forced cancellation, but of course might not
actually lead to termination if caught.
And lastly, if you are willing to accept that cancellation might not be
possible in all cases, then it would be possible to implement a kind of
"safe_cancel" that can fail (cancellation not possible) or throw some kind
of exception that cannot be caught, which means the guard callback could
be called within the normal coro context.
The choice of a Deliantra, the free code+content MORPG
-----==- _GNU_ http://www.deliantra.net
----==-- _ generation
---==---(_)__ __ ____ __ Marc Lehmann
--==---/ / _ \/ // /\ \/ / schmorp at schmorp.de
More information about the anyevent