diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-10-24 17:36:35 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-10-24 17:36:35 +0200 |
commit | 8e33d8a2ca89d630f8890332df7e5737fc4608c8 (patch) | |
tree | eb4ee9a8f5f1164f09438c7c40315ac63c19039d /src/lane.h | |
parent | 0d94a88b4de3973ce99fd77c6731c8219444db9e (diff) | |
download | lanes-8e33d8a2ca89d630f8890332df7e5737fc4608c8.tar.gz lanes-8e33d8a2ca89d630f8890332df7e5737fc4608c8.tar.bz2 lanes-8e33d8a2ca89d630f8890332df7e5737fc4608c8.zip |
Modernized some more trifles
Diffstat (limited to 'src/lane.h')
-rw-r--r-- | src/lane.h | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -43,6 +43,13 @@ static constexpr std::string_view kLaneMetatableName{ "Lane" }; | |||
43 | #define kLanesLibName "lanes" | 43 | #define kLanesLibName "lanes" |
44 | #define kLanesCoreLibName kLanesLibName ".core" | 44 | #define kLanesCoreLibName kLanesLibName ".core" |
45 | 45 | ||
46 | // for cancel() argument | ||
47 | enum class WakeLane | ||
48 | { | ||
49 | No, | ||
50 | Yes | ||
51 | }; | ||
52 | |||
46 | // NOTE: values to be changed by either thread, during execution, without locking, are marked "volatile" | 53 | // NOTE: values to be changed by either thread, during execution, without locking, are marked "volatile" |
47 | class Lane | 54 | class Lane |
48 | { | 55 | { |
@@ -136,20 +143,26 @@ class Lane | |||
136 | // this one is for us, to make sure memory is freed by the correct allocator | 143 | // this one is for us, to make sure memory is freed by the correct allocator |
137 | static void operator delete(void* p_) { static_cast<Lane*>(p_)->U->internalAllocator.free(p_, sizeof(Lane)); } | 144 | static void operator delete(void* p_) { static_cast<Lane*>(p_)->U->internalAllocator.free(p_, sizeof(Lane)); } |
138 | 145 | ||
139 | Lane(Universe* U_, lua_State* L_, ErrorTraceLevel errorTraceLevel_, bool asCoroutine_); | ||
140 | ~Lane(); | 146 | ~Lane(); |
147 | Lane(Universe* U_, lua_State* L_, ErrorTraceLevel errorTraceLevel_, bool asCoroutine_); | ||
148 | |||
149 | // rule of 5 | ||
150 | Lane(Lane const&) = delete; | ||
151 | Lane(Lane&&) = delete; | ||
152 | Lane& operator=(Lane const&) = delete; | ||
153 | Lane& operator=(Lane&&) = delete; | ||
141 | 154 | ||
142 | private: | 155 | private: |
143 | 156 | ||
144 | [[nodiscard]] CancelResult internalCancel(CancelRequest rq_, std::chrono::time_point<std::chrono::steady_clock> until_, bool wakeLane_); | 157 | [[nodiscard]] CancelResult internalCancel(CancelRequest rq_, std::chrono::time_point<std::chrono::steady_clock> until_, WakeLane wakeLane_); |
145 | 158 | ||
146 | public: | 159 | public: |
147 | 160 | ||
148 | CancelResult cancel(CancelOp op_, int hookCount_, std::chrono::time_point<std::chrono::steady_clock> until_, bool wakeLane_); | 161 | CancelResult cancel(CancelOp op_, std::chrono::time_point<std::chrono::steady_clock> until_, WakeLane wakeLane_, int hookCount_); |
149 | void changeDebugName(StackIndex nameIdx_); | 162 | void changeDebugName(StackIndex nameIdx_); |
150 | void closeState() | 163 | void closeState() |
151 | { | 164 | { |
152 | lua_State* _L{ S }; | 165 | lua_State* const _L{ S }; |
153 | S = nullptr; | 166 | S = nullptr; |
154 | L = nullptr; | 167 | L = nullptr; |
155 | nresults = 0; | 168 | nresults = 0; |