aboutsummaryrefslogtreecommitdiff
path: root/src/lane.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lane.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lane.cpp b/src/lane.cpp
index e88a213..9f68c91 100644
--- a/src/lane.cpp
+++ b/src/lane.cpp
@@ -901,7 +901,7 @@ Lane::~Lane()
901 901
902// ################################################################################################# 902// #################################################################################################
903 903
904CancelResult Lane::cancel(CancelOp const op_, int const hookCount_, std::chrono::time_point<std::chrono::steady_clock> const until_, bool const wakeLane_) 904CancelResult Lane::cancel(CancelOp const op_, std::chrono::time_point<std::chrono::steady_clock> const until_, WakeLane const wakeLane_, int const hookCount_)
905{ 905{
906 // this is a hook installed with lua_sethook: can't capture anything to be convertible to lua_Hook 906 // this is a hook installed with lua_sethook: can't capture anything to be convertible to lua_Hook
907 static constexpr lua_Hook _cancelHook{ 907 static constexpr lua_Hook _cancelHook{
@@ -915,17 +915,17 @@ CancelResult Lane::cancel(CancelOp const op_, int const hookCount_, std::chrono:
915 }; 915 };
916 916
917 // remember that lanes are not transferable: only one thread can cancel a lane, so no multithreading issue here 917 // remember that lanes are not transferable: only one thread can cancel a lane, so no multithreading issue here
918 // We can read 'lane_->status' without locks, but not wait for it (if Posix no PTHREAD_TIMEDJOIN) 918 // We can read status without locks, but not wait for it (if Posix no PTHREAD_TIMEDJOIN)
919 if (status >= Lane::Done) { 919 if (status >= Lane::Done) {
920 // say "ok" by default, including when lane is already done 920 // say "ok" by default, including when lane is already done
921 return CancelResult::Cancelled; 921 return CancelResult::Cancelled;
922 } 922 }
923 923
924 // signal the linda the wake up the thread so that it can react to the cancel query 924 // signal the linda to wake up the thread so that it can react to the cancel query
925 // let us hope we never land here with a pointer on a linda that has been destroyed... 925 // let us hope we never land here with a pointer on a linda that has been destroyed...
926 if (op_ == CancelOp::Soft) { 926 if (op_ == CancelOp::Soft) {
927 return internalCancel(CancelRequest::Soft, until_, wakeLane_); 927 return internalCancel(CancelRequest::Soft, until_, wakeLane_);
928 } else if (static_cast<int>(op_) > static_cast<int>(CancelOp::Soft)) { 928 } else if (op_ > CancelOp::Soft) {
929 lua_sethook(L, _cancelHook, static_cast<int>(op_), hookCount_); 929 lua_sethook(L, _cancelHook, static_cast<int>(op_), hookCount_);
930 } 930 }
931 931
@@ -934,13 +934,13 @@ CancelResult Lane::cancel(CancelOp const op_, int const hookCount_, std::chrono:
934 934
935// ################################################################################################# 935// #################################################################################################
936 936
937[[nodiscard]] CancelResult Lane::internalCancel(CancelRequest const rq_, std::chrono::time_point<std::chrono::steady_clock> const until_, bool const wakeLane_) 937[[nodiscard]] CancelResult Lane::internalCancel(CancelRequest const rq_, std::chrono::time_point<std::chrono::steady_clock> const until_, WakeLane const wakeLane_)
938{ 938{
939 cancelRequest = rq_; // it's now signaled to stop 939 cancelRequest = rq_; // it's now signaled to stop
940 if (rq_ == CancelRequest::Hard) { 940 if (rq_ == CancelRequest::Hard) {
941 // lane_->thread.get_stop_source().request_stop(); 941 // lane_->thread.get_stop_source().request_stop();
942 } 942 }
943 if (wakeLane_) { // wake the thread so that execution returns from any pending linda operation if desired 943 if (wakeLane_ == WakeLane::Yes) { // wake the thread so that execution returns from any pending linda operation if desired
944 std::condition_variable* const _waiting_on{ waiting_on }; 944 std::condition_variable* const _waiting_on{ waiting_on };
945 if (status == Lane::Waiting && _waiting_on != nullptr) { 945 if (status == Lane::Waiting && _waiting_on != nullptr) {
946 _waiting_on->notify_all(); 946 _waiting_on->notify_all();