32#include <condition_variable>
42#define THREADSLEEP(tick) std::this_thread::sleep_for(std::chrono::seconds(tick))
80#define MUTEX_INITIALIZER \
82#define MUTEXINIT(mutex) \
85#define MUTEXDESTROY(mutex) \
92using namespace std::this_thread;
98using Promise = std::promise<Tp>;
100using Future = std::future<Tp>;
101template <
typename Tp>
116template <
typename Tp>
124 static std::vector<Mutex*> _mutexes;
125 if(_n > _mutexes.size())
126 _mutexes.resize(_n,
nullptr);
128 _mutexes[_n] =
new Mutex();
129 return *(_mutexes[_n - 1]);
138template <
typename Tp>
146 static std::vector<RecursiveMutex*> _mutexes;
147 if(_n > _mutexes.size())
148 _mutexes.resize(_n,
nullptr);
151 return *(_mutexes[_n - 1]);
161#define MUTEXLOCK(mutex) \
165#define MUTEXUNLOCK(mutex) \
171#define THREADJOIN(worker) (worker).join()
178template <
typename WorkerT,
typename FuncT,
typename... Args>
182 *worker =
Thread(func, std::forward<Args>(args)...);
190#define CONDITION_INITIALIZER \
192#define CONDITIONWAIT(cond, lock) (cond)->wait(*lock);
193#define CONDITIONWAITLAMBDA(cond, lock, lambda) (cond)->wait(*lock, lambda);
194#define CONDITIONNOTIFY(cond) (cond)->notify_one();
195#define CONDITIONBROADCAST(cond) (cond)->notify_all();
G4int(*)(G4Mutex *) thread_unlock
G4int(*)(G4Mutex *) thread_lock
int WorkerThreadLeavesPool()
unsigned GetNumberOfCores()
int WorkerThreadJoinsPool()
void SetThreadId(int aNewValue)
int GetNumberOfRunningWorkerThreads()
bool SetPinAffinity(int idx, NativeThread &at)
std::thread::native_handle_type NativeThread
std::recursive_mutex RecursiveMutex
std::promise< Tp > Promise
void * ThreadFunReturnType
std::condition_variable Condition
RecursiveMutex & TypeRecursiveMutex(const unsigned int &_n=0)
Mutex & TypeMutex(const unsigned int &_n=0)
void THREADCREATE(WorkerT *&worker, FuncT func, Args... args)
std::shared_future< Tp > SharedFuture