diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-04-09 10:12:30 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-04-09 10:12:30 +0200 |
commit | 23f25f3a9d327153e4c16ca86d937ec334803a10 (patch) | |
tree | 110826adcf29554cd59768acdccf3de006e8a7f4 /src/universe.h | |
parent | 9b5c27af793a08fd17d1fde93e9512e76536f484 (diff) | |
download | lanes-23f25f3a9d327153e4c16ca86d937ec334803a10.tar.gz lanes-23f25f3a9d327153e4c16ca86d937ec334803a10.tar.bz2 lanes-23f25f3a9d327153e4c16ca86d937ec334803a10.zip |
C++ migration: still more threading code cleanup. 'sudo' global moved in the Universe
Diffstat (limited to '')
-rw-r--r-- | src/universe.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/universe.h b/src/universe.h index 38885cb..f4211af 100644 --- a/src/universe.h +++ b/src/universe.h | |||
@@ -119,9 +119,17 @@ class ProtectedAllocator : public AllocatorDefinition | |||
119 | 119 | ||
120 | // everything regarding the Lanes universe is stored in that global structure | 120 | // everything regarding the Lanes universe is stored in that global structure |
121 | // held as a full userdata in the master Lua state that required it for the first time | 121 | // held as a full userdata in the master Lua state that required it for the first time |
122 | // don't forget to initialize all members in LG_configure() | 122 | class Universe |
123 | struct Universe | ||
124 | { | 123 | { |
124 | public: | ||
125 | |||
126 | #ifdef PLATFORM_LINUX | ||
127 | // Linux needs to check, whether it's been run as root | ||
128 | bool const m_sudo{ geteuid() == 0 }; | ||
129 | #else | ||
130 | bool const m_sudo{ false }; | ||
131 | #endif // PLATFORM_LINUX | ||
132 | |||
125 | // for verbose errors | 133 | // for verbose errors |
126 | bool verboseErrors{ false }; | 134 | bool verboseErrors{ false }; |
127 | 135 | ||
@@ -155,6 +163,7 @@ struct Universe | |||
155 | // require() serialization | 163 | // require() serialization |
156 | std::recursive_mutex require_cs; | 164 | std::recursive_mutex require_cs; |
157 | 165 | ||
166 | // metatable unique identifiers | ||
158 | std::atomic<lua_Integer> next_mt_id{ 1 }; | 167 | std::atomic<lua_Integer> next_mt_id{ 1 }; |
159 | 168 | ||
160 | #if USE_DEBUG_SPEW() | 169 | #if USE_DEBUG_SPEW() |
@@ -165,6 +174,13 @@ struct Universe | |||
165 | // After a lane has removed itself from the chain, it still performs some processing. | 174 | // After a lane has removed itself from the chain, it still performs some processing. |
166 | // The terminal desinit sequence should wait for all such processing to terminate before force-killing threads | 175 | // The terminal desinit sequence should wait for all such processing to terminate before force-killing threads |
167 | std::atomic<int> selfdestructing_count{ 0 }; | 176 | std::atomic<int> selfdestructing_count{ 0 }; |
177 | |||
178 | Universe(); | ||
179 | ~Universe() = default; | ||
180 | Universe(Universe const&) = delete; | ||
181 | Universe(Universe&&) = delete; | ||
182 | Universe& operator=(Universe const&) = delete; | ||
183 | Universe& operator=(Universe&&) = delete; | ||
168 | }; | 184 | }; |
169 | 185 | ||
170 | // ################################################################################################ | 186 | // ################################################################################################ |