aboutsummaryrefslogtreecommitdiff
path: root/src/cancel.hpp
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-12-03 17:13:35 +0100
committerBenoit Germain <benoit.germain@ubisoft.com>2024-12-03 17:13:35 +0100
commitd8580e14fec64dd5bf3dd492a4811b290cbe4aec (patch)
tree8dcd3117f7427671e34509badd4c08957d8f0914 /src/cancel.hpp
parent307fd830eb168005a3ba3d557343284814757eff (diff)
downloadlanes-d8580e14fec64dd5bf3dd492a4811b290cbe4aec.tar.gz
lanes-d8580e14fec64dd5bf3dd492a4811b290cbe4aec.tar.bz2
lanes-d8580e14fec64dd5bf3dd492a4811b290cbe4aec.zip
Internal rework of an enum bad practice usage
Diffstat (limited to 'src/cancel.hpp')
-rw-r--r--src/cancel.hpp27
1 files changed, 7 insertions, 20 deletions
diff --git a/src/cancel.hpp b/src/cancel.hpp
index 8f4cf07..65ccf8d 100644
--- a/src/cancel.hpp
+++ b/src/cancel.hpp
@@ -6,36 +6,25 @@
6// ################################################################################################# 6// #################################################################################################
7 7
8// Lane cancellation request modes 8// Lane cancellation request modes
9enum class CancelRequest 9enum class CancelRequest : uint8_t
10{ 10{
11 None, // no pending cancel request 11 None, // no pending cancel request
12 Soft, // user wants the lane to cancel itself manually on cancel_test() 12 Soft, // user wants the lane to cancel itself manually on cancel_test()
13 Hard // user wants the lane to be interrupted (meaning code won't return from those functions) from inside linda:send/receive calls 13 Hard // user wants the lane to be interrupted (meaning code won't return from those functions) from inside linda:send/receive calls
14}; 14};
15 15
16enum class CancelResult 16struct CancelOp
17{ 17{
18 Timeout, 18 CancelRequest mode;
19 Cancelled 19 LuaHookMask hookMask;
20}; 20};
21 21
22enum class CancelOp 22enum class CancelResult : uint8_t
23{ 23{
24 Invalid = -2, 24 Timeout,
25 Hard = -1, 25 Cancelled
26 Soft = 0,
27 MaskCall = LUA_MASKCALL,
28 MaskRet = LUA_MASKRET,
29 MaskLine = LUA_MASKLINE,
30 MaskCount = LUA_MASKCOUNT,
31 MaskAll = LUA_MASKCALL | LUA_MASKRET | LUA_MASKLINE | LUA_MASKCOUNT
32}; 26};
33 27
34inline auto operator<=>(CancelOp const a_, CancelOp const b_)
35{
36 return static_cast<std::underlying_type_t<CancelOp>>(a_) <=> static_cast<std::underlying_type_t<CancelOp>>(b_);
37}
38
39// xxh64 of string "kCancelError" generated at https://www.pelock.com/products/hash-calculator 28// xxh64 of string "kCancelError" generated at https://www.pelock.com/products/hash-calculator
40static constexpr UniqueKey kCancelError{ 0x0630345FEF912746ull, "lanes.cancel_error" }; // 'raise_cancel_error' sentinel 29static constexpr UniqueKey kCancelError{ 0x0630345FEF912746ull, "lanes.cancel_error" }; // 'raise_cancel_error' sentinel
41 30
@@ -43,8 +32,6 @@ static constexpr UniqueKey kCancelError{ 0x0630345FEF912746ull, "lanes.cancel_er
43 32
44[[nodiscard]] 33[[nodiscard]]
45CancelRequest CheckCancelRequest(lua_State* L_); 34CancelRequest CheckCancelRequest(lua_State* L_);
46[[nodiscard]]
47CancelOp WhichCancelOp(std::string_view const& opString_);
48 35
49// ################################################################################################# 36// #################################################################################################
50 37