Commit a4cffed8 authored by Andrew Smith's avatar Andrew Smith Committed by Facebook GitHub Bot

Immediately cancel any running transform callback on sender cancellation

Summary: Currently, when we get a cancelled notification on the output sender for a transform, we schedule the cancellation of any running transform callback on an executor. CancellationSource is thread-safe, so we don't need to do this. This diff ensures that cancelling the output receiver will immediately trigger cancellation of any running transform callback, allowing the transform callback to deterministically know that it has been cancelled.

Reviewed By: aary

Differential Revision: D32191796

fbshipit-source-id: aabd58be9b58b0f560b8127b336e626c3482a644
parent 85724a41
......@@ -158,8 +158,8 @@ class SenderCancellationCallback : public IChannelCallback {
* if the callback was not previously triggered.
*/
void consume(ChannelBridgeBase*) override {
cancelSource_.requestCancellation();
executor_->add([=]() {
cancelSource_.requestCancellation();
CHECK(!callbackToFire_.isFulfilled());
callbackToFire_.setValue(CallbackToFire::Consume);
});
......@@ -170,8 +170,8 @@ class SenderCancellationCallback : public IChannelCallback {
* if the callback was not previously triggered.
*/
void canceled(ChannelBridgeBase*) override {
cancelSource_.requestCancellation();
executor_->add([=]() {
cancelSource_.requestCancellation();
CHECK(!callbackToFire_.isFulfilled());
callbackToFire_.setValue(CallbackToFire::Canceled);
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment