-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to cancel a linked thread without killing self #25
Comments
@ozataman Could you please describe your use case? (I'm collecting different concurrency patterns) This code: bracket (asyncLinked child_code) cancelLinked $ \_ ->
main_code seems to be equivalent to the next: snd <$> concurrently child_code main_code Does it cover your use case? |
I have a similar problem. That's why I created issue request #64 |
I actually don't like I'm curious, in your use case for |
I recently had another use case where 4-5 long running async threads were getting created throughout the application that had to be up and running simultaneously at all times - and if one died, I wanted the whole thing to die and retry from scratch. After experiencing quite a bit of unreliability (possibly of my own making) from using I do wonder if my original use case, which was quite a bit more complex, would allow for that as well. May be worth a look at some point. |
I wanted to be able to a <- async $ handle (\ThreadKilled -> return ()) $ ...
link a
...
cancel a which works because However, according to the
So, using a special exception that is only raised by My use case for |
I doubt this matters in practice very often, but I believe there's a race between forking the asyncLinked :: IO () -> IO (Async ())
asyncLinked action = do
mask $ \restore -> do
a <- async $ handle (ThreadKilled -> return ()) (restore action)
restore $ do
U.link a
return a Re my use case, what I want is a program that fails fast when any of its threads fail with an uncaught exception. With the default behavior of unlinked Why not change |
This is now done, see b015e01 |
Great! To help future code archeologists, commits relevant to fixing this issue (and #64) included
|
I wonder if anybody has run into this pattern (and whether I'm missing something in the existing functionality that could already do it):
The text was updated successfully, but these errors were encountered: