diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-05-30 17:57:21 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-05-30 17:57:21 +0200 |
commit | 731556711e453a501f1d1d06a6013b8fbd53414e (patch) | |
tree | 4c5c28cd83de320fcf4c9b4c749f2e6e8d5bef48 /src/universe.h | |
parent | a156aaeb07fada043b308409dcffcae1726eec0b (diff) | |
download | lanes-731556711e453a501f1d1d06a6013b8fbd53414e.tar.gz lanes-731556711e453a501f1d1d06a6013b8fbd53414e.tar.bz2 lanes-731556711e453a501f1d1d06a6013b8fbd53414e.zip |
Keeper management modernisation and improvements
* use a std::variant to manage the distinction between one or more keeper states. Use std::unique_ptr<Keeper[]> to manage the multiple keeper case.
* setting "nb_keepers" renamed "nb_user_keepers", to indicate these are in addition to internal keeper #0 used for timers.
* stricter lanes.linda() argument checking. group is imposed if more than one keeper is used.
* more tests
Diffstat (limited to 'src/universe.h')
-rw-r--r-- | src/universe.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/universe.h b/src/universe.h index 7624fed..7b9f309 100644 --- a/src/universe.h +++ b/src/universe.h | |||
@@ -9,10 +9,12 @@ extern "C" | |||
9 | } | 9 | } |
10 | #endif // __cplusplus | 10 | #endif // __cplusplus |
11 | 11 | ||
12 | #include "keeper.h" | ||
12 | #include "lanesconf.h" | 13 | #include "lanesconf.h" |
13 | #include "tracker.h" | 14 | #include "tracker.h" |
14 | #include "uniquekey.h" | 15 | #include "uniquekey.h" |
15 | 16 | ||
17 | #include <atomic> | ||
16 | #include <mutex> | 18 | #include <mutex> |
17 | 19 | ||
18 | // ################################################################################################# | 20 | // ################################################################################################# |
@@ -20,7 +22,6 @@ extern "C" | |||
20 | // forwards | 22 | // forwards |
21 | enum class CancelOp; | 23 | enum class CancelOp; |
22 | struct DeepPrelude; | 24 | struct DeepPrelude; |
23 | struct Keepers; | ||
24 | class Lane; | 25 | class Lane; |
25 | 26 | ||
26 | // ################################################################################################# | 27 | // ################################################################################################# |
@@ -144,7 +145,7 @@ class Universe | |||
144 | 145 | ||
145 | AllocatorDefinition internalAllocator; | 146 | AllocatorDefinition internalAllocator; |
146 | 147 | ||
147 | Keepers* keepers{ nullptr }; | 148 | Keepers keepers; |
148 | 149 | ||
149 | // Initialized by 'init_once_LOCKED()': the deep userdata Linda object | 150 | // Initialized by 'init_once_LOCKED()': the deep userdata Linda object |
150 | // used for timers (each lane will get a proxy to this) | 151 | // used for timers (each lane will get a proxy to this) |
@@ -183,12 +184,10 @@ class Universe | |||
183 | Universe& operator=(Universe const&) = delete; | 184 | Universe& operator=(Universe const&) = delete; |
184 | Universe& operator=(Universe&&) = delete; | 185 | Universe& operator=(Universe&&) = delete; |
185 | 186 | ||
186 | void closeKeepers(); | ||
187 | [[nodiscard]] static Universe* Create(lua_State* L_); | 187 | [[nodiscard]] static Universe* Create(lua_State* L_); |
188 | [[nodiscard]] static inline Universe* Get(lua_State* L_); | 188 | [[nodiscard]] static inline Universe* Get(lua_State* L_); |
189 | void initializeAllocatorFunction(lua_State* L_); | 189 | void initializeAllocatorFunction(lua_State* L_); |
190 | static int InitializeFinalizer(lua_State* L_); | 190 | static int InitializeFinalizer(lua_State* L_); |
191 | void initializeKeepers(lua_State* L_); | ||
192 | static inline void Store(lua_State* L_, Universe* U_); | 191 | static inline void Store(lua_State* L_, Universe* U_); |
193 | void terminateFreeRunningLanes(lua_State* L_, lua_Duration shutdownTimeout_, CancelOp op_); | 192 | void terminateFreeRunningLanes(lua_State* L_, lua_Duration shutdownTimeout_, CancelOp op_); |
194 | }; | 193 | }; |