Skip to content

Conversation

@simonmar
Copy link
Owner

No description provided.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I think we could throw here.

Comment on lines +12 to +13
-- | A more flexible way to create 'Async's and have them automatically
-- cancelled when the 'Warden' is shut down.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@simonmar simonmar merged commit adc5146 into master Jul 10, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants