Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
Threading.hh File Reference
#include "PTL/Globals.hh"
#include "PTL/Types.hh"
#include <chrono>
#include <condition_variable>
#include <future>
#include <mutex>
#include <thread>
#include <vector>

Go to the source code of this file.

Namespaces

namespace  PTL
 
namespace  PTL::ThisThread
 
namespace  PTL::Threading
 

Macros

#define THREADSLEEP(tick)   std::this_thread::sleep_for(std::chrono::seconds(tick))
 
#define MUTEX_INITIALIZER    {}
 
#define MUTEXINIT(mutex)
 
#define MUTEXDESTROY(mutex)
 
#define MUTEXLOCK(mutex)
 
#define MUTEXUNLOCK(mutex)
 
#define THREADJOIN(worker)   (worker).join()
 
#define CONDITION_INITIALIZER    {}
 
#define CONDITIONWAIT(cond, lock)   (cond)->wait(*lock);
 
#define CONDITIONWAITLAMBDA(cond, lock, lambda)   (cond)->wait(*lock, lambda);
 
#define CONDITIONNOTIFY(cond)   (cond)->notify_one();
 
#define CONDITIONBROADCAST(cond)   (cond)->notify_all();
 

Typedefs

template<typename Tp >
using PTL::Future = std::future< Tp >
 
template<typename Tp >
using PTL::SharedFuture = std::shared_future< Tp >
 
template<typename Tp >
using PTL::Promise = std::promise< Tp >
 
typedef std::mutex PTL::Mutex
 
typedef std::recursive_mutex PTL::RecursiveMutex
 
typedef void * PTL::ThreadFunReturnType
 
typedef void * PTL::ThreadFunArgType
 
typedef int(* PTL::thread_lock) (Mutex *)
 
typedef int(* PTL::thread_unlock) (Mutex *)
 
typedef std::thread PTL::Thread
 
typedef std::thread::native_handle_type PTL::NativeThread
 
typedef std::thread::id PTL::Pid_t
 
typedef std::condition_variable PTL::Condition
 
typedef Thread::id PTL::ThreadId
 

Enumerations

enum  { PTL::Threading::SEQUENTIAL_ID = -2 , PTL::Threading::MASTER_ID = -1 , PTL::Threading::WORKER_ID = 0 , PTL::Threading::GENERICTHREAD_ID = -1000 }
 

Functions

template<typename Tp >
Mutex & PTL::TypeMutex (const unsigned int &_n=0)
 
template<typename Tp >
RecursiveMutex & PTL::TypeRecursiveMutex (const unsigned int &_n=0)
 
template<typename WorkerT , typename FuncT , typename... Args>
void PTL::THREADCREATE (WorkerT *&worker, FuncT func, Args... args)
 
Pid_t PTL::Threading::GetPidId ()
 
unsigned PTL::Threading::GetNumberOfCores ()
 
int PTL::Threading::GetThreadId ()
 
bool PTL::Threading::IsWorkerThread ()
 
bool PTL::Threading::IsMasterThread ()
 
void PTL::Threading::SetThreadId (int aNewValue)
 
bool PTL::Threading::SetPinAffinity (int idx, NativeThread &at)
 
int PTL::Threading::WorkerThreadLeavesPool ()
 
int PTL::Threading::WorkerThreadJoinsPool ()
 
int PTL::Threading::GetNumberOfRunningWorkerThreads ()
 

Macro Definition Documentation

◆ CONDITION_INITIALIZER

#define CONDITION_INITIALIZER    {}

Definition at line 190 of file Threading.hh.

◆ CONDITIONBROADCAST

#define CONDITIONBROADCAST (   cond)    (cond)->notify_all();

Definition at line 195 of file Threading.hh.

◆ CONDITIONNOTIFY

#define CONDITIONNOTIFY (   cond)    (cond)->notify_one();

Definition at line 194 of file Threading.hh.

◆ CONDITIONWAIT

#define CONDITIONWAIT (   cond,
  lock 
)    (cond)->wait(*lock);

Definition at line 192 of file Threading.hh.

◆ CONDITIONWAITLAMBDA

#define CONDITIONWAITLAMBDA (   cond,
  lock,
  lambda 
)    (cond)->wait(*lock, lambda);

Definition at line 193 of file Threading.hh.

◆ MUTEX_INITIALIZER

#define MUTEX_INITIALIZER    {}

Definition at line 80 of file Threading.hh.

◆ MUTEXDESTROY

#define MUTEXDESTROY (   mutex)
Value:
; \
;

Definition at line 85 of file Threading.hh.

◆ MUTEXINIT

#define MUTEXINIT (   mutex)
Value:
; \
;

Definition at line 82 of file Threading.hh.

◆ MUTEXLOCK

#define MUTEXLOCK (   mutex)
Value:
{ \
(mutex)->lock(); \
}

Definition at line 161 of file Threading.hh.

◆ MUTEXUNLOCK

#define MUTEXUNLOCK (   mutex)
Value:
{ \
(mutex)->unlock(); \
}

Definition at line 165 of file Threading.hh.

◆ THREADJOIN

#define THREADJOIN (   worker)    (worker).join()

Definition at line 171 of file Threading.hh.

◆ THREADSLEEP

#define THREADSLEEP (   tick)    std::this_thread::sleep_for(std::chrono::seconds(tick))

Definition at line 42 of file Threading.hh.