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

Cancelation Problem #813

Open
emil14 opened this issue Dec 18, 2024 · 4 comments
Open

Cancelation Problem #813

emil14 opened this issue Dec 18, 2024 · 4 comments
Assignees
Labels

Comments

@emil14
Copy link
Collaborator

emil14 commented Dec 18, 2024

In Go there's a way to stop goroutine from executing. It's a simple pattern where all you need to do is to pass a channel to that function. That functions must guarantee (compiler doesn't enforce though) to stop as soon as channel will be closed.

Go design extends this pattern with first class support for for loops where you can range over channel messages. For loop will automatically break after channel is closed. Another construct that is frequently used with this pattern is select with case for cancelation channel. Go does even next step and implements half of this pattern with context.Context data-type that has Done() method that returns a channel you can block on. As soon as context is closed (by timeout or manual call to cancel func), the channel that Done() returns also closes.

Go however solves two problems with this data-type, it also allows to use it as a context in react-sense i.e. to share data without explicit drilling. That is a separate problem #812 that doesn't have to be solved in Nevalang exactly this way. Even thought it could be.

This was referenced Dec 18, 2024
@default-writer
Copy link

default-writer commented Jan 11, 2025

Indeed, that will simplify coding for loops but in terms of clean and nice graceful shutdown it might me required to customise this process and gave programmer the ability to exit on his own conditions or his own cases making the default behaviour works only if custom cancellation token processing omitted completely in user space code and not in library code they are using

@default-writer
Copy link

Please take a look into the ##custodians section: https://nikhilism.com/post/2023/racket-beyond-languages/

@default-writer
Copy link

Also, in general about CML and different languages and ideas: https://wingolog.org/archives/2016/09/21/is-go-an-acceptable-cml

@emil14 emil14 self-assigned this Jan 14, 2025
@emil14 emil14 added the Minor label Jan 14, 2025
@emil14
Copy link
Collaborator Author

emil14 commented Jan 15, 2025

Indeed, that will simplify coding for loops but in terms of clean and nice graceful shutdown it might me required to customise this process and gave programmer the ability to exit on his own conditions or his own cases making the default behaviour works only if custom cancellation token processing omitted completely in user space code and not in library code they are using

@default-writer thanks, this issue doesn't propose (yet) some solution e.g. automatic cancelation (I don't have clear vision how this could work at the moment), but your point is valid - in case there will be something like that, we need to be sure it scales well for cases where custom logic is needed

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

No branches or pull requests

2 participants