Geant4 11.3.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Threading.hh File Reference
#include "G4Types.hh"
#include "globals.hh"
#include <chrono>
#include <condition_variable>
#include <future>
#include <mutex>
#include <thread>
#include <vector>

Go to the source code of this file.

Classes

class  G4DummyThread
 

Namespaces

namespace  G4ThisThread
 
namespace  G4Threading
 

Macros

#define G4THREADSLEEP(tick)
 
#define G4MUTEX_INITIALIZER    {}
 
#define G4MUTEXINIT(mutex)
 
#define G4MUTEXDESTROY(mutex)
 
#define G4MUTEXLOCK(mutex)
 
#define G4MUTEXUNLOCK(mutex)
 
#define G4THREADJOIN(worker)
 
#define G4CONDITION_INITIALIZER   1
 
#define G4CONDITIONWAIT(cond, mutex)
 
#define G4CONDITIONWAITLAMBDA(cond, mutex, lambda)
 
#define G4CONDITIONNOTIFY(cond)
 
#define G4CONDITIONBROADCAST(cond)
 

Typedefs

template<typename _Tp>
using G4Future = std::future<_Tp>
 
template<typename _Tp>
using G4SharedFuture = std::shared_future<_Tp>
 
template<typename _Tp>
using G4Promise = std::promise<_Tp>
 
using G4Mutex = std::mutex
 
using G4RecursiveMutex = std::recursive_mutex
 
using G4ThreadFunReturnType = void*
 
using G4ThreadFunArgType = void*
 
using thread_lock
 
using thread_unlock
 
using G4Thread = G4DummyThread
 
using G4NativeThread = G4DummyThread::native_handle_type
 
using G4Pid_t = G4int
 
using G4Condition = G4int
 
using G4ThreadId = G4Thread::id
 

Enumerations

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

Functions

template<typename _Tp>
G4MutexG4TypeMutex ()
 
template<typename _Tp>
G4RecursiveMutexG4TypeRecursiveMutex ()
 
template<typename _Worker, typename _Func, typename... _Args>
void G4THREADCREATE (_Worker *&worker, _Func func, _Args... args)
 
G4Pid_t G4Threading::G4GetPidId ()
 
G4int G4Threading::G4GetNumberOfCores ()
 
G4int G4Threading::G4GetThreadId ()
 
G4bool G4Threading::IsWorkerThread ()
 
G4bool G4Threading::IsMasterThread ()
 
void G4Threading::G4SetThreadId (G4int aNewValue)
 
G4bool G4Threading::G4SetPinAffinity (G4int idx, G4NativeThread &at)
 
void G4Threading::SetMultithreadedApplication (G4bool value)
 
G4bool G4Threading::IsMultithreadedApplication ()
 
G4int G4Threading::WorkerThreadLeavesPool ()
 
G4int G4Threading::WorkerThreadJoinsPool ()
 
G4int G4Threading::GetNumberOfRunningWorkerThreads ()
 

Macro Definition Documentation

◆ G4CONDITION_INITIALIZER

#define G4CONDITION_INITIALIZER   1

Definition at line 258 of file G4Threading.hh.

◆ G4CONDITIONBROADCAST

#define G4CONDITIONBROADCAST ( cond)

◆ G4CONDITIONNOTIFY

#define G4CONDITIONNOTIFY ( cond)
Value:

Definition at line 262 of file G4Threading.hh.

◆ G4CONDITIONWAIT

#define G4CONDITIONWAIT ( cond,
mutex )
Value:

Definition at line 259 of file G4Threading.hh.

Referenced by G4MTBarrier::ThisWorkerReady(), and G4MTBarrier::Wait().

◆ G4CONDITIONWAITLAMBDA

#define G4CONDITIONWAITLAMBDA ( cond,
mutex,
lambda )
Value:
G4ConsumeParameters(cond, mutex, lambda);

Definition at line 260 of file G4Threading.hh.

260# define G4CONDITIONWAITLAMBDA(cond, mutex, lambda) \
261 G4ConsumeParameters(cond, mutex, lambda);

Referenced by G4Qt3DViewer::MovingToVisSubThread(), and G4Qt3DViewer::SwitchToVisSubThread().

◆ G4MUTEX_INITIALIZER

#define G4MUTEX_INITIALIZER    {}

Definition at line 85 of file G4Threading.hh.

85#define G4MUTEX_INITIALIZER \
86 {}

Referenced by G4_DECLARE_XS_FACTORY(), G4_DECLARE_XS_FACTORY(), and G4_DECLARE_XS_FACTORY().

◆ G4MUTEXDESTROY

◆ G4MUTEXINIT

◆ G4MUTEXLOCK

◆ G4MUTEXUNLOCK

◆ G4THREADJOIN

#define G4THREADJOIN ( worker)
Value:
; \
;

Definition at line 243 of file G4Threading.hh.

243# define G4THREADJOIN(worker) \
244 ; \
245 ;

Referenced by G4UserTaskThreadInitialization::JoinWorker().

◆ G4THREADSLEEP

#define G4THREADSLEEP ( tick)
Value:
std::this_thread::sleep_for(std::chrono::seconds(tick))

Definition at line 50 of file G4Threading.hh.

50#define G4THREADSLEEP(tick) \
51 std::this_thread::sleep_for(std::chrono::seconds(tick))

Referenced by G4WorkerSubEvtRunManager::DoWork(), and G4SubEvtRunManager::RunTermination().

Typedef Documentation

◆ G4Condition

using G4Condition = G4int

Definition at line 257 of file G4Threading.hh.

◆ G4Future

template<typename _Tp>
using G4Future = std::future<_Tp>

Definition at line 55 of file G4Threading.hh.

◆ G4Mutex

using G4Mutex = std::mutex

Definition at line 81 of file G4Threading.hh.

◆ G4NativeThread

◆ G4Pid_t

using G4Pid_t = G4int

Definition at line 247 of file G4Threading.hh.

◆ G4Promise

template<typename _Tp>
using G4Promise = std::promise<_Tp>

Definition at line 59 of file G4Threading.hh.

◆ G4RecursiveMutex

using G4RecursiveMutex = std::recursive_mutex

Definition at line 82 of file G4Threading.hh.

◆ G4SharedFuture

template<typename _Tp>
using G4SharedFuture = std::shared_future<_Tp>

Definition at line 57 of file G4Threading.hh.

◆ G4Thread

Definition at line 231 of file G4Threading.hh.

◆ G4ThreadFunArgType

using G4ThreadFunArgType = void*

Definition at line 111 of file G4Threading.hh.

◆ G4ThreadFunReturnType

using G4ThreadFunReturnType = void*

Definition at line 110 of file G4Threading.hh.

◆ G4ThreadId

Definition at line 270 of file G4Threading.hh.

◆ thread_lock

using thread_lock
Initial value:
G4int (*)(G4Mutex*)
std::mutex G4Mutex
int G4int
Definition G4Types.hh:85

Definition at line 112 of file G4Threading.hh.

◆ thread_unlock

Initial value:
G4int (*)(G4Mutex*)

Definition at line 114 of file G4Threading.hh.

Function Documentation

◆ G4THREADCREATE()

template<typename _Worker, typename _Func, typename... _Args>
void G4THREADCREATE ( _Worker *& worker,
_Func func,
_Args... args )

Definition at line 252 of file G4Threading.hh.

253{
254 *worker = G4Thread(func, std::forward<_Args>(args)...);
255}
G4DummyThread G4Thread

◆ G4TypeMutex()

template<typename _Tp>
G4Mutex & G4TypeMutex ( )

◆ G4TypeRecursiveMutex()

template<typename _Tp>
G4RecursiveMutex & G4TypeRecursiveMutex ( )

Definition at line 138 of file G4Threading.hh.

139{
140 static G4RecursiveMutex _mutex;
141 return _mutex;
142}
std::recursive_mutex G4RecursiveMutex