| 170 | |
| 171 | template <typename C> |
| 172 | class InitMutex |
| 173 | { |
| 174 | private: |
| 175 | std::atomic<bool> flag; |
| 176 | #ifdef DEV_BUILD |
| 177 | const char* from; |
| 178 | #endif |
| 179 | public: |
| 180 | explicit InitMutex(const char* f) |
| 181 | : flag(false) |
| 182 | #ifdef DEV_BUILD |
| 183 | , from(f) |
| 184 | #define FB_LOCKED_FROM from |
| 185 | #else |
| 186 | #define FB_LOCKED_FROM NULL |
| 187 | #endif |
| 188 | { } |
| 189 | void init() |
| 190 | { |
| 191 | if (!flag) |
| 192 | { |
| 193 | MutexLockGuard guard(*StaticMutex::mutex, FB_LOCKED_FROM); |
| 194 | if (!flag) |
| 195 | { |
| 196 | C::init(); |
| 197 | flag = true; |
| 198 | } |
| 199 | } |
| 200 | } |
| 201 | void cleanup() |
| 202 | { |
| 203 | if (flag) |
no outgoing calls
no test coverage detected