ZeroErr
threadsafe.h
Go to the documentation of this file.
1 #pragma once
3 
4 // Thread safety support
5 #ifdef ZEROERR_NO_THREAD_SAFE
6 
7 #define ZEROERR_MUTEX(x)
8 #define ZEROERR_LOCK(x)
9 #define ZEROERR_ATOMIC(x) x
10 #define ZEROERR_LOAD(x) x
11 
12 #else
13 
14 #define ZEROERR_MUTEX(x) static std::mutex x;
15 #define ZEROERR_LOCK(x) std::lock_guard<std::mutex> lock(x);
16 #define ZEROERR_ATOMIC(x) std::atomic<x>
17 #define ZEROERR_LOAD(x) x.load()
18 
19 #include <atomic>
20 #include <mutex>
21 
22 #endif