diff options
Diffstat (limited to 'src/lane.cpp')
-rw-r--r-- | src/lane.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/lane.cpp b/src/lane.cpp index 15499fe..9751aeb 100644 --- a/src/lane.cpp +++ b/src/lane.cpp | |||
@@ -832,13 +832,16 @@ Lane::~Lane() | |||
832 | 832 | ||
833 | // ################################################################################################# | 833 | // ################################################################################################# |
834 | 834 | ||
835 | CancelResult Lane::cancel(CancelOp op_, int hookCount_, std::chrono::time_point<std::chrono::steady_clock> until_, bool wakeLane_) | 835 | CancelResult Lane::cancel(CancelOp const op_, int const hookCount_, std::chrono::time_point<std::chrono::steady_clock> const until_, bool const wakeLane_) |
836 | { | 836 | { |
837 | auto _cancel_hook = +[](lua_State* const L_, [[maybe_unused]] lua_Debug* const ar_) { | 837 | // this is a hook installed with lua_sethook: can't capture anything to be convertible to lua_Hook |
838 | DEBUGSPEW_CODE(DebugSpew(nullptr) << "cancel_hook" << std::endl); | 838 | static constexpr lua_Hook _cancelHook{ |
839 | if (cancel_test(L_) != CancelRequest::None) { | 839 | +[](lua_State* const L_, [[maybe_unused]] lua_Debug* const ar_) { |
840 | lua_sethook(L_, nullptr, 0, 0); | 840 | DEBUGSPEW_CODE(DebugSpew(nullptr) << "cancel_hook" << std::endl); |
841 | raise_cancel_error(L_); | 841 | if (CheckCancelRequest(L_) != CancelRequest::None) { |
842 | lua_sethook(L_, nullptr, 0, 0); | ||
843 | raise_cancel_error(L_); | ||
844 | } | ||
842 | } | 845 | } |
843 | }; | 846 | }; |
844 | 847 | ||
@@ -854,7 +857,7 @@ CancelResult Lane::cancel(CancelOp op_, int hookCount_, std::chrono::time_point< | |||
854 | if (op_ == CancelOp::Soft) { | 857 | if (op_ == CancelOp::Soft) { |
855 | return cancelSoft(until_, wakeLane_); | 858 | return cancelSoft(until_, wakeLane_); |
856 | } else if (static_cast<int>(op_) > static_cast<int>(CancelOp::Soft)) { | 859 | } else if (static_cast<int>(op_) > static_cast<int>(CancelOp::Soft)) { |
857 | lua_sethook(L, _cancel_hook, static_cast<int>(op_), hookCount_); | 860 | lua_sethook(L, _cancelHook, static_cast<int>(op_), hookCount_); |
858 | } | 861 | } |
859 | 862 | ||
860 | return cancelHard(until_, wakeLane_); | 863 | return cancelHard(until_, wakeLane_); |