Conversation
Control/Concurrent/Async/Warden.hs
Outdated
| this <- fixIO $ \this -> mask_ $ Async.asyncWithUnmask $ \unmask -> | ||
| action unmask `finally` forget (Warden v) this | ||
| return (Just $ HashSet.insert (void this) asyncs, this) | ||
| Nothing -> (,) Nothing <$> Async.async (throwIO Async.AsyncCancelled) |
There was a problem hiding this comment.
Do I understand correctly that if I don't wait the resulting async, I'll never notice that I'm trying to spawn into an already shut warden? Is there any specific reason why not just fail immediately?
There was a problem hiding this comment.
yes, I think we could throw here.
| -- | A more flexible way to create 'Async's and have them automatically | ||
| -- cancelled when the 'Warden' is shut down. |
There was a problem hiding this comment.
I don't know what's your use case, but this is an example of a more general pattern, see e.g. https://hackage.haskell.org/package/io-region
(For the record: I'm not suggesting anything, just my 2c.)
There was a problem hiding this comment.
The use case I have is Glean (https://github.com/facebookincubator/Glean/blob/main/glean/db/Glean/Database/Env.hs#L102) and this also came up in a discussion on discourse https://discourse.haskell.org/t/multitasking-a-new-concurrency-library/12409/1
I think it's simple enough that we don't need to implement it in terms of anything else, but thanks for the pointer.
No description provided.