diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-10-24 17:36:35 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-10-24 17:36:35 +0200 |
commit | 8e33d8a2ca89d630f8890332df7e5737fc4608c8 (patch) | |
tree | eb4ee9a8f5f1164f09438c7c40315ac63c19039d /src/cancel.cpp | |
parent | 0d94a88b4de3973ce99fd77c6731c8219444db9e (diff) | |
download | lanes-8e33d8a2ca89d630f8890332df7e5737fc4608c8.tar.gz lanes-8e33d8a2ca89d630f8890332df7e5737fc4608c8.tar.bz2 lanes-8e33d8a2ca89d630f8890332df7e5737fc4608c8.zip |
Modernized some more trifles
Diffstat (limited to 'src/cancel.cpp')
-rw-r--r-- | src/cancel.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/cancel.cpp b/src/cancel.cpp index b14dca6..2d0b807 100644 --- a/src/cancel.cpp +++ b/src/cancel.cpp | |||
@@ -138,14 +138,14 @@ LUAG_FUNC(cancel_test) | |||
138 | 138 | ||
139 | // ################################################################################################# | 139 | // ################################################################################################# |
140 | 140 | ||
141 | // bool[,reason] = lane_h:cancel( [mode, hookcount] [, timeout] [, wake_lane]) | 141 | // bool[,reason] = lane_h:cancel( [cancel_op, hookcount] [, timeout] [, wake_lane]) |
142 | LUAG_FUNC(thread_cancel) | 142 | LUAG_FUNC(thread_cancel) |
143 | { | 143 | { |
144 | Lane* const _lane{ ToLane(L_, StackIndex{ 1 }) }; | 144 | Lane* const _lane{ ToLane(L_, StackIndex{ 1 }) }; |
145 | CancelOp const _op{ WhichCancelOp(L_, StackIndex{ 2 }) }; // this removes the op string from the stack | 145 | CancelOp const _op{ WhichCancelOp(L_, StackIndex{ 2 }) }; // this removes the cancel_op string from the stack |
146 | 146 | ||
147 | int _hook_count{ 0 }; | 147 | int _hook_count{ 0 }; |
148 | if (static_cast<int>(_op) > static_cast<int>(CancelOp::Soft)) { // hook is requested | 148 | if (_op > CancelOp::Soft) { // hook is requested |
149 | _hook_count = static_cast<int>(luaL_checkinteger(L_, 2)); | 149 | _hook_count = static_cast<int>(luaL_checkinteger(L_, 2)); |
150 | lua_remove(L_, 2); // argument is processed, remove it | 150 | lua_remove(L_, 2); // argument is processed, remove it |
151 | if (_hook_count < 1) { | 151 | if (_hook_count < 1) { |
@@ -167,23 +167,23 @@ LUAG_FUNC(thread_cancel) | |||
167 | } | 167 | } |
168 | 168 | ||
169 | // we wake by default in "hard" mode (remember that hook is hard too), but this can be turned off if desired | 169 | // we wake by default in "hard" mode (remember that hook is hard too), but this can be turned off if desired |
170 | bool _wake_lane{ _op != CancelOp::Soft }; | 170 | WakeLane _wake_lane{ _op != CancelOp::Soft ? WakeLane::Yes : WakeLane::No }; |
171 | if (lua_gettop(L_) >= 2) { | 171 | if (lua_gettop(L_) >= 2) { |
172 | if (!lua_isboolean(L_, 2)) { | 172 | if (!lua_isboolean(L_, 2)) { |
173 | raise_luaL_error(L_, "wake_lindas argument is not a boolean"); | 173 | raise_luaL_error(L_, "wake_lane argument is not a boolean"); |
174 | } | 174 | } |
175 | _wake_lane = lua_toboolean(L_, 2) ? true : false; | 175 | _wake_lane = lua_toboolean(L_, 2) ? WakeLane::Yes : WakeLane::No; |
176 | lua_remove(L_, 2); // argument is processed, remove it | 176 | lua_remove(L_, 2); // argument is processed, remove it |
177 | } | 177 | } |
178 | STACK_CHECK_START_REL(L_, 0); | 178 | STACK_CHECK_START_REL(L_, 0); |
179 | switch (_lane->cancel(_op, _hook_count, _until, _wake_lane)) { | 179 | switch (_lane->cancel(_op, _until, _wake_lane, _hook_count)) { |
180 | default: // should never happen unless we added a case and forgot to handle it | 180 | default: // should never happen unless we added a case and forgot to handle it |
181 | raise_luaL_error(L_, "should not get here!"); | 181 | raise_luaL_error(L_, "should not get here!"); |
182 | break; | 182 | break; |
183 | 183 | ||
184 | case CancelResult::Timeout: | 184 | case CancelResult::Timeout: |
185 | lua_pushboolean(L_, 0); // false | 185 | lua_pushboolean(L_, 0); // false |
186 | lua_pushstring(L_, "timeout"); // false "timeout" | 186 | luaG_pushstring(L_, "timeout"); // false "timeout" |
187 | break; | 187 | break; |
188 | 188 | ||
189 | case CancelResult::Cancelled: | 189 | case CancelResult::Cancelled: |