Skip to content
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

Effect cancellation #247

Open
charypar opened this issue May 31, 2024 · 3 comments
Open

Effect cancellation #247

charypar opened this issue May 31, 2024 · 3 comments

Comments

@charypar
Copy link
Member

charypar commented May 31, 2024

On a number of occassions I've ended up implementing domain specific signaling in capabilities for canceling effects. This is especially useful for subscriptions.

There are two directions:

  • Shell cancells a subscription, communicating that the stream has eneded
  • Core is no longer interested in the subscription (the relevant task has ended)

In the latter case, attempting to resolve the effect again will, I'm pretty sure, result in a panic at the moment, which is not ideal.

It would be good if Crux could automatically signal to the shell that the subscription has been terminated and any related resources on the shell side can be cleaned up.

@charypar charypar moved this to Core and Capabilities in Crux Development Roadmap May 31, 2024
@obmarg
Copy link
Collaborator

obmarg commented May 31, 2024

Just dropping my idea for implementing the core->shell side of this from my chat w/ @charypar

  1. Each App/Executor/Whatever has a synchronous unbounded MPSC for dead subscriptions
  2. Each stream gets a sender for that when they start (probably at the point they are first awaited rather than created, though 🤷 whatevers easiest)
  3. We add a Drop impl to our stream struct that sends a message on the channel
  4. At the end of each event loop run we look in this channel and create "i'm a dead stream" messages to pass up to the shell

There's probably some details that'd need worked out, but I think the approach would work

@fraschm1998
Copy link

Does #279 close this issue and if so will it also update on the roadmap? https://github.com/orgs/redbadger/projects/11

@charypar
Copy link
Member Author

charypar commented Dec 6, 2024

It does not - it only adds cancellation to timers and makes it an explicit part of the time capability protocol. This issue is about supporting this for all effects without the capability having to explicitly implement the cancellation semantics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Core and Capabilities
Development

No branches or pull requests

3 participants