diff options
Diffstat (limited to 'src/lane.h')
-rw-r--r-- | src/lane.h | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -64,6 +64,14 @@ class Lane | |||
64 | }; | 64 | }; |
65 | using enum Status; | 65 | using enum Status; |
66 | 66 | ||
67 | enum class ErrorTraceLevel | ||
68 | { | ||
69 | Minimal, // no error handler function when running the lane body | ||
70 | Basic, // lane body errors caught by a error handler | ||
71 | Extended // same as above, but with more data extracted from the debug infos | ||
72 | }; | ||
73 | using enum ErrorTraceLevel; | ||
74 | |||
67 | // the thread | 75 | // the thread |
68 | std::jthread thread; | 76 | std::jthread thread; |
69 | // a latch to wait for the lua_State to be ready | 77 | // a latch to wait for the lua_State to be ready |
@@ -104,10 +112,11 @@ class Lane | |||
104 | // S: cleans up after itself if non-nullptr at lane exit | 112 | // S: cleans up after itself if non-nullptr at lane exit |
105 | 113 | ||
106 | #if HAVE_LANE_TRACKING() | 114 | #if HAVE_LANE_TRACKING() |
115 | // For tracking only | ||
107 | Lane* volatile tracking_next{ nullptr }; | 116 | Lane* volatile tracking_next{ nullptr }; |
108 | #endif // HAVE_LANE_TRACKING() | 117 | #endif // HAVE_LANE_TRACKING() |
109 | // | 118 | |
110 | // For tracking only | 119 | ErrorTraceLevel const errorTraceLevel{ Basic }; |
111 | 120 | ||
112 | [[nodiscard]] static void* operator new(size_t size_, Universe* U_) noexcept { return U_->internalAllocator.alloc(size_); } | 121 | [[nodiscard]] static void* operator new(size_t size_, Universe* U_) noexcept { return U_->internalAllocator.alloc(size_); } |
113 | // can't actually delete the operator because the compiler generates stack unwinding code that could call it in case of exception | 122 | // can't actually delete the operator because the compiler generates stack unwinding code that could call it in case of exception |
@@ -115,18 +124,20 @@ class Lane | |||
115 | // this one is for us, to make sure memory is freed by the correct allocator | 124 | // this one is for us, to make sure memory is freed by the correct allocator |
116 | static void operator delete(void* p_) { static_cast<Lane*>(p_)->U->internalAllocator.free(p_, sizeof(Lane)); } | 125 | static void operator delete(void* p_) { static_cast<Lane*>(p_)->U->internalAllocator.free(p_, sizeof(Lane)); } |
117 | 126 | ||
118 | Lane(Universe* U_, lua_State* L_); | 127 | Lane(Universe* U_, lua_State* L_, ErrorTraceLevel errorTraceLevel_); |
119 | ~Lane(); | 128 | ~Lane(); |
120 | 129 | ||
121 | void changeDebugName(int nameIdx_); | 130 | void changeDebugName(int nameIdx_); |
122 | void close() { lua_State* _L{ L }; L = nullptr; lua_close(_L); } | 131 | void close() { lua_State* _L{ L }; L = nullptr; lua_close(_L); } |
132 | [[nodiscard]] char const* errorTraceLevelString() const; | ||
133 | [[nodiscard]] int pushErrorHandler() const; | ||
134 | void pushErrorTraceLevel(lua_State* L_) const; | ||
135 | static void PushMetatable(lua_State* L_); | ||
123 | void pushThreadStatus(lua_State* L_) const; | 136 | void pushThreadStatus(lua_State* L_) const; |
124 | void securizeDebugName(lua_State* L_); | 137 | void securizeDebugName(lua_State* L_); |
125 | void startThread(int priority_); | 138 | void startThread(int priority_); |
126 | [[nodiscard]] char const* threadStatusString() const; | 139 | [[nodiscard]] char const* threadStatusString() const; |
127 | [[nodiscard]] bool waitForCompletion(std::chrono::time_point<std::chrono::steady_clock> until_); | 140 | [[nodiscard]] bool waitForCompletion(std::chrono::time_point<std::chrono::steady_clock> until_); |
128 | |||
129 | static void PushMetatable(lua_State* L_); | ||
130 | }; | 141 | }; |
131 | 142 | ||
132 | // ################################################################################################# | 143 | // ################################################################################################# |