diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-10-28 17:57:31 +0100 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-10-28 17:57:31 +0100 |
commit | 76da2875eb2af9f8191c2adf4f9663ac3a2cec89 (patch) | |
tree | 112bd51318e401bf8745123919a635e765365318 /src/cancel.h | |
parent | cb6e1c2f3b93d5de02de4a8c8f13891e33674a36 (diff) | |
download | lanes-76da2875eb2af9f8191c2adf4f9663ac3a2cec89.tar.gz lanes-76da2875eb2af9f8191c2adf4f9663ac3a2cec89.tar.bz2 lanes-76da2875eb2af9f8191c2adf4f9663ac3a2cec89.zip |
Renamed allocator.h → allocator.hpp, cancel.h → cancel.hpp, keeper.h → keeper.hpp, tools.h → tools.hpp
Diffstat (limited to 'src/cancel.h')
-rw-r--r-- | src/cancel.h | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/src/cancel.h b/src/cancel.h deleted file mode 100644 index 7230169..0000000 --- a/src/cancel.h +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include "macros_and_utils.hpp" | ||
4 | #include "uniquekey.hpp" | ||
5 | |||
6 | // ################################################################################################# | ||
7 | |||
8 | // Lane cancellation request modes | ||
9 | enum class CancelRequest | ||
10 | { | ||
11 | None, // no pending cancel request | ||
12 | // TODO: add a Wake mode: user wants to wake the waiting lindas (in effect resulting in a timeout before the initial operation duration) | ||
13 | Soft, // user wants the lane to cancel itself manually on cancel_test() | ||
14 | Hard // user wants the lane to be interrupted (meaning code won't return from those functions) from inside linda:send/receive calls | ||
15 | }; | ||
16 | |||
17 | enum class CancelResult | ||
18 | { | ||
19 | Timeout, | ||
20 | Cancelled | ||
21 | }; | ||
22 | |||
23 | enum class CancelOp | ||
24 | { | ||
25 | Invalid = -2, | ||
26 | Hard = -1, | ||
27 | Soft = 0, | ||
28 | MaskCall = LUA_MASKCALL, | ||
29 | MaskRet = LUA_MASKRET, | ||
30 | MaskLine = LUA_MASKLINE, | ||
31 | MaskCount = LUA_MASKCOUNT, | ||
32 | MaskAll = LUA_MASKCALL | LUA_MASKRET | LUA_MASKLINE | LUA_MASKCOUNT | ||
33 | }; | ||
34 | |||
35 | inline auto operator<=>(CancelOp const a_, CancelOp const b_) | ||
36 | { | ||
37 | return static_cast<std::underlying_type_t<CancelOp>>(a_) <=> static_cast<std::underlying_type_t<CancelOp>>(b_); | ||
38 | } | ||
39 | |||
40 | // xxh64 of string "kCancelError" generated at https://www.pelock.com/products/hash-calculator | ||
41 | static constexpr UniqueKey kCancelError{ 0x0630345FEF912746ull, "lanes.cancel_error" }; // 'raise_cancel_error' sentinel | ||
42 | |||
43 | // ################################################################################################# | ||
44 | |||
45 | [[nodiscard]] CancelRequest CheckCancelRequest(lua_State* L_); | ||
46 | [[nodiscard]] CancelOp WhichCancelOp(std::string_view const& opString_); | ||
47 | |||
48 | // ################################################################################################# | ||
49 | |||
50 | [[noreturn]] static inline void raise_cancel_error(lua_State* const L_) | ||
51 | { | ||
52 | STACK_GROW(L_, 1); | ||
53 | kCancelError.pushKey(L_); // special error value | ||
54 | raise_lua_error(L_); | ||
55 | } | ||
56 | |||
57 | // ################################################################################################# | ||
58 | |||
59 | LUAG_FUNC(cancel_test); | ||
60 | LUAG_FUNC(lane_cancel); | ||