aboutsummaryrefslogtreecommitdiff
path: root/src/lane.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lane.hpp')
-rw-r--r--src/lane.hpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/lane.hpp b/src/lane.hpp
index 9b678d6..bd328b1 100644
--- a/src/lane.hpp
+++ b/src/lane.hpp
@@ -56,6 +56,7 @@ class Lane final
56 /* 56 /*
57 Pending: The Lua VM hasn't done anything yet. 57 Pending: The Lua VM hasn't done anything yet.
58 Resuming: The user requested the lane to resume execution from Suspended state. 58 Resuming: The user requested the lane to resume execution from Suspended state.
59 Closing: The user is joining the lane, specifically interrupting a suspended Lane.
59 Suspended: returned from lua_resume, waiting for the client to request a lua_resume. 60 Suspended: returned from lua_resume, waiting for the client to request a lua_resume.
60 Running, Suspended, Waiting: Thread is inside the Lua VM. 61 Running, Suspended, Waiting: Thread is inside the Lua VM.
61 Done, Error, Cancelled: Thread execution is outside the Lua VM. It can be lua_close()d. 62 Done, Error, Cancelled: Thread execution is outside the Lua VM. It can be lua_close()d.
@@ -66,6 +67,7 @@ class Lane final
66 Running, 67 Running,
67 Suspended, 68 Suspended,
68 Resuming, 69 Resuming,
70 Closing,
69 Waiting, 71 Waiting,
70 Done, 72 Done,
71 Error, 73 Error,
@@ -139,6 +141,10 @@ class Lane final
139 141
140 ErrorTraceLevel const errorTraceLevel{ Basic }; 142 ErrorTraceLevel const errorTraceLevel{ Basic };
141 143
144 // when Universe is collected, and an uncooperative Lane refuses to terminate, this flag becomes true
145 // in case of crash, that's the Lane's fault!
146 std::atomic_bool flaggedAfterUniverseGC{ false };
147
142 [[nodiscard]] 148 [[nodiscard]]
143 static void* operator new(size_t size_, Universe* U_) noexcept { return U_->internalAllocator.alloc(size_); } 149 static void* operator new(size_t size_, Universe* U_) noexcept { return U_->internalAllocator.alloc(size_); }
144 // can't actually delete the operator because the compiler generates stack unwinding code that could call it in case of exception 150 // can't actually delete the operator because the compiler generates stack unwinding code that could call it in case of exception
@@ -195,12 +201,14 @@ class Lane final
195 static void PushMetatable(lua_State* L_); 201 static void PushMetatable(lua_State* L_);
196 void pushStatusString(lua_State* L_) const; 202 void pushStatusString(lua_State* L_) const;
197 void pushIndexedResult(lua_State* L_, int key_) const; 203 void pushIndexedResult(lua_State* L_, int key_) const;
204 [[nodiscard]]
205 int pushStoredResults(lua_State* L_) const;
198 void resetResultsStorage(lua_State* L_, StackIndex self_idx_); 206 void resetResultsStorage(lua_State* L_, StackIndex self_idx_);
199 void selfdestructAdd(); 207 void selfdestructAdd();
200 [[nodiscard]] 208 [[nodiscard]]
201 bool selfdestructRemove(); 209 bool selfdestructRemove();
202 void securizeDebugName(lua_State* L_); 210 void securizeDebugName(lua_State* L_);
203 void startThread(int priority_); 211 void startThread(lua_State* L_, int priority_, NativePrioFlag native_);
204 void storeDebugName( std::string_view const& name_); 212 void storeDebugName( std::string_view const& name_);
205 [[nodiscard]] 213 [[nodiscard]]
206 int storeResults(lua_State* L_); 214 int storeResults(lua_State* L_);
@@ -208,7 +216,9 @@ class Lane final
208 std::string_view threadStatusString() const; 216 std::string_view threadStatusString() const;
209 // wait until the lane stops working with its state (either Suspended or Done+) 217 // wait until the lane stops working with its state (either Suspended or Done+)
210 [[nodiscard]] 218 [[nodiscard]]
211 bool waitForCompletion(std::chrono::time_point<std::chrono::steady_clock> until_); 219 bool waitForCompletion(std::chrono::time_point<std::chrono::steady_clock> until_, bool const _acceptSuspended);
220 [[nodiscard]]
221 bool waitForJoin(lua_State* _L, std::chrono::time_point<std::chrono::steady_clock> until_);
212}; 222};
213 223
214// ################################################################################################# 224// #################################################################################################