From 30296957f7526644011c3ae589d7bdcaf82b457e Mon Sep 17 00:00:00 2001 From: Pavel Baykov Date: Tue, 29 Mar 2022 10:48:13 -0300 Subject: [PATCH] add cancel sync, filter out wait for canceled tasks --- src/thread/future.cpp | 1 + src/thread/thread_d.hpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/thread/future.cpp b/src/thread/future.cpp index 2111584..95485b9 100755 --- a/src/thread/future.cpp +++ b/src/thread/future.cpp @@ -27,6 +27,7 @@ namespace fc { } void promise_base::cancel(const char* reason /* = nullptr */){ + synchronized(_spin_yield) // wlog("${desc} canceled!", ("desc", _desc? _desc : "")); _canceled = true; #ifndef NDEBUG diff --git a/src/thread/thread_d.hpp b/src/thread/thread_d.hpp index 8e36b14..2a6c995 100755 --- a/src/thread/thread_d.hpp +++ b/src/thread/thread_d.hpp @@ -596,7 +596,12 @@ namespace fc { else if( timeout_time != time_point::min() ) { // there may be tasks that have been canceled we should filter them out now - // rather than waiting... + // rather than waiting... + // + + if (current->canceled){ + return; + } /* This bit is kind of sloppy -- this wait was originally implemented as a wait