-
Notifications
You must be signed in to change notification settings - Fork 419
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
Add co-operative cancellation to async writer and passthrough source #1414
Add co-operative cancellation to async writer and passthrough source #1414
Conversation
Motivation: Whenever we create continuations we should be careful to add support for co-operative cancellation via a cancellation handler. Modifications: - Add co-operative cancellation to the async write and passthrough source - Tests Result: Better cancellation support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two small issues.
} | ||
} | ||
} onCancel: { | ||
self.cancelAsynchronously() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, this should just be cancel
. No need to create another task.
self.cancelAsynchronously() | |
self.cancel() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work unfortunately: Actor-isolated instance method 'cancel()' can not be referenced from a Sendable closure
IIUC onCancel
is not executed on the actor but a different thread (which makes sense as it runs immediately when cancelled), so I think this makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
urgh. makes sense.
throw GRPCAsyncWriterError.tooManyPendingWrites | ||
} | ||
} onCancel: { | ||
self.cancelAsynchronously() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for redispatch into the AsyncWriter
self.cancelAsynchronously() | |
self.cancel() |
Motivation:
Whenever we create continuations we should be careful to add support for
co-operative cancellation via a cancellation handler.
Modifications:
source
Result:
Better cancellation support