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
proposal: context: new method WithCallbackOnCancel(...) #57325
Comments
Why should this be in the standard library? https://go.dev/doc/faq#x_in_std |
not sure how it answers my proposal
this callback can be running in a new goroutine, so it won't be blocked. it could be a simple func() with no return value. The main idea is to be able to trigger on canceling without keeping the running goroutine for checking the context state. |
for downvoters: read this proposal as "event driven" vs "polling" approach. |
|
sorry, but it has nothing in common with "event driven". its literally "polling" approach |
Given that we currently have a canonical way to do this, and it hasn't been demonstrated to be a widespread need (eg by third party libraries implementing custom contexts with this feature), I think https://go.dev/doc/faq#x_in_std is the best answer. |
It would be great to have
context.WithCallbackOnCancel(...)
in order to get rid of goroutine usage to read the canceling channel.Is there any chance to see it in the near future?
The text was updated successfully, but these errors were encountered: