diff options
Diffstat (limited to '')
-rw-r--r-- | src/lanes_private.h | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/lanes_private.h b/src/lanes_private.h index 01d43c0..3ed52fe 100644 --- a/src/lanes_private.h +++ b/src/lanes_private.h | |||
@@ -17,6 +17,22 @@ class Lane | |||
17 | { | 17 | { |
18 | public: | 18 | public: |
19 | 19 | ||
20 | /* | ||
21 | Pending: The Lua VM hasn't done anything yet. | ||
22 | Running, Waiting: Thread is inside the Lua VM. If the thread is forcefully stopped, we can't lua_close() the Lua State. | ||
23 | Done, Error, Cancelled: Thread execution is outside the Lua VM. It can be lua_close()d. | ||
24 | */ | ||
25 | enum class Status | ||
26 | { | ||
27 | Pending, | ||
28 | Running, | ||
29 | Waiting, | ||
30 | Done, | ||
31 | Error, | ||
32 | Cancelled | ||
33 | }; | ||
34 | using enum Status; | ||
35 | |||
20 | // the thread | 36 | // the thread |
21 | std::jthread m_thread; | 37 | std::jthread m_thread; |
22 | // a latch to wait for the lua_State to be ready | 38 | // a latch to wait for the lua_State to be ready |
@@ -36,16 +52,16 @@ class Lane | |||
36 | // M: prepares the state, and reads results | 52 | // M: prepares the state, and reads results |
37 | // S: while S is running, M must keep out of modifying the state | 53 | // S: while S is running, M must keep out of modifying the state |
38 | 54 | ||
39 | volatile enum e_status status{ PENDING }; | 55 | Status volatile m_status{ Pending }; |
40 | // | 56 | // |
41 | // M: sets to PENDING (before launching) | 57 | // M: sets to Pending (before launching) |
42 | // S: updates -> RUNNING/WAITING -> DONE/ERROR_ST/CANCELLED | 58 | // S: updates -> Running/Waiting -> Done/Error/Cancelled |
43 | 59 | ||
44 | std::condition_variable* volatile m_waiting_on{ nullptr }; | 60 | std::condition_variable* volatile m_waiting_on{ nullptr }; |
45 | // | 61 | // |
46 | // When status is WAITING, points on the linda's signal the thread waits on, else nullptr | 62 | // When status is Waiting, points on the linda's signal the thread waits on, else nullptr |
47 | 63 | ||
48 | volatile CancelRequest cancel_request{ CancelRequest::None }; | 64 | CancelRequest volatile cancel_request{ CancelRequest::None }; |
49 | // | 65 | // |
50 | // M: sets to false, flags true for cancel request | 66 | // M: sets to false, flags true for cancel request |
51 | // S: reads to see if cancel is requested | 67 | // S: reads to see if cancel is requested |