diff options
Diffstat (limited to '')
-rw-r--r-- | src/lane.h (renamed from src/lanes_private.h) | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/src/lanes_private.h b/src/lane.h index a756c42..f28a402 100644 --- a/src/lanes_private.h +++ b/src/lane.h | |||
@@ -10,6 +10,30 @@ | |||
10 | #include <stop_token> | 10 | #include <stop_token> |
11 | #include <thread> | 11 | #include <thread> |
12 | 12 | ||
13 | // ################################################################################################# | ||
14 | |||
15 | /* | ||
16 | * registry[FINALIZER_REG_KEY] is either nil (no finalizers) or a table | ||
17 | * of functions that Lanes will call after the executing 'pcall' has ended. | ||
18 | * | ||
19 | * We're NOT using the GC system for finalizer mainly because providing the | ||
20 | * error (and maybe stack trace) parameters to the finalizer functions would | ||
21 | * anyways complicate that approach. | ||
22 | */ | ||
23 | // xxh64 of string "kFinalizerRegKey" generated at https://www.pelock.com/products/hash-calculator | ||
24 | static constexpr RegistryUniqueKey kFinalizerRegKey{ 0xFE936BFAA718FEEAull }; | ||
25 | |||
26 | // xxh64 of string "kExtendedStackTraceRegKey" generated at https://www.pelock.com/products/hash-calculator | ||
27 | static constexpr RegistryUniqueKey kExtendedStackTraceRegKey{ 0x38147AD48FB426E2ull }; // used as registry key | ||
28 | |||
29 | // xxh64 of string "kLaneGC" generated at https://www.pelock.com/products/hash-calculator | ||
30 | static constexpr UniqueKey kLaneGC{ 0x5D6122141727F960ull }; | ||
31 | |||
32 | // xxh64 of string "kLanePointerRegKey" generated at https://www.pelock.com/products/hash-calculator | ||
33 | static constexpr RegistryUniqueKey kLanePointerRegKey{ 0x2D8CF03FE9F0A51Aull }; // used as registry key | ||
34 | |||
35 | // ################################################################################################# | ||
36 | |||
13 | // The chain is ended by '(Lane*)(-1)', not nullptr: 'selfdestructFirst -> ... -> ... -> (-1)' | 37 | // The chain is ended by '(Lane*)(-1)', not nullptr: 'selfdestructFirst -> ... -> ... -> (-1)' |
14 | #define SELFDESTRUCT_END ((Lane*) (-1)) | 38 | #define SELFDESTRUCT_END ((Lane*) (-1)) |
15 | 39 | ||
@@ -94,15 +118,17 @@ class Lane | |||
94 | Lane(Universe* U_, lua_State* L_); | 118 | Lane(Universe* U_, lua_State* L_); |
95 | ~Lane(); | 119 | ~Lane(); |
96 | 120 | ||
97 | [[nodiscard]] bool waitForCompletion(std::chrono::time_point<std::chrono::steady_clock> until_); | ||
98 | void startThread(int priority_); | ||
99 | void pushThreadStatus(lua_State* L_); | ||
100 | void changeDebugName(int nameIdx_); | 121 | void changeDebugName(int nameIdx_); |
122 | void pushThreadStatus(lua_State* L_) const; | ||
101 | void securizeDebugName(lua_State* L_); | 123 | void securizeDebugName(lua_State* L_); |
124 | void startThread(int priority_); | ||
125 | char const* threadStatusString() const; | ||
126 | [[nodiscard]] bool waitForCompletion(std::chrono::time_point<std::chrono::steady_clock> until_); | ||
127 | |||
128 | static void PushMetatable(lua_State* L_); | ||
102 | }; | 129 | }; |
103 | 130 | ||
104 | // xxh64 of string "kLanePointerRegKey" generated at https://www.pelock.com/products/hash-calculator | 131 | // ################################################################################################# |
105 | static constexpr RegistryUniqueKey kLanePointerRegKey{ 0x2D8CF03FE9F0A51Aull }; // used as registry key | ||
106 | 132 | ||
107 | // To allow free-running threads (longer lifespan than the handle's) | 133 | // To allow free-running threads (longer lifespan than the handle's) |
108 | // 'Lane' are malloc/free'd and the handle only carries a pointer. | 134 | // 'Lane' are malloc/free'd and the handle only carries a pointer. |