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

Add co-operative cancellation to async writer and passthrough source #1414

Merged
merged 2 commits into from
May 27, 2022

Conversation

glbrntt
Copy link
Collaborator

@glbrntt glbrntt commented May 27, 2022

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

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
@glbrntt glbrntt requested a review from fabianfett May 27, 2022 11:56
Copy link
Collaborator

@fabianfett fabianfett left a 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()
Copy link
Collaborator

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.

Suggested change
self.cancelAsynchronously()
self.cancel()

Copy link
Collaborator Author

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.

Copy link
Collaborator

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()
Copy link
Collaborator

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

Suggested change
self.cancelAsynchronously()
self.cancel()

@glbrntt glbrntt merged commit 0680b7b into grpc:1.7.1-async-await May 27, 2022
@glbrntt glbrntt deleted the gb-co-op-cancellation branch May 27, 2022 12:50
@glbrntt glbrntt added the 🔨 semver/patch No public API change. label Jun 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants