Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
|
Namespaces | |
namespace | internal |
namespace | mpl |
namespace | tbb |
namespace | ThisThread |
namespace | thread_pool |
namespace | Threading |
Classes | |
class | Backtrace |
class | EnvSettings |
struct | JoinFunction |
struct | JoinFunction< void, JoinArg > |
struct | JoinFunction< void, void > |
class | PackagedTask |
The task class is supplied to thread_pool. More... | |
struct | ScopeDestructor |
class | Singleton |
Singleton object that allows a deleter class to be specified. More... | |
class | Task |
The task class is supplied to thread_pool. More... | |
class | Task< RetT, void > |
The task class is supplied to thread_pool. More... | |
class | Task< void, void > |
The task class is supplied to thread_pool. More... | |
class | TaskFuture |
The task class is supplied to thread_pool. More... | |
class | TaskGroup |
class | TaskManager |
class | TaskRunManager |
class | TaskSubQueue |
class | TemplateAutoLock |
class | ThreadData |
class | ThreadPool |
class | Timer |
class | UserTaskQueue |
class | VTask |
VTask is the abstract class stored in thread_pool. More... | |
class | VUserTaskQueue |
Typedefs | |
using | AutoLock = TemplateAutoLock<Mutex> |
using | RecursiveAutoLock = TemplateAutoLock<RecursiveMutex> |
template<typename FuncT , typename... ArgTypes> | |
using | ResultOf_t = typename std::result_of<FuncT(ArgTypes...)>::type |
template<typename T > | |
using | decay_t = typename std::decay<T>::type |
template<bool B, typename T = void> | |
using | enable_if_t = typename std::enable_if<B, T>::type |
template<typename Tp , typename Arg = Tp> | |
using | TBBTaskGroup = TaskGroup<Tp, Arg> |
using | tbb_global_control_t = tbb::global_control |
using | tbb_task_group_t = tbb::task_group |
using | tbb_task_arena_t = tbb::task_arena |
using | Thread = std::thread |
using | NativeThread = std::thread::native_handle_type |
using | Pid_t = std::thread::id |
using | Condition = std::condition_variable |
using | ThreadId = Thread::id |
template<typename Tp > | |
using | Future = std::future<Tp> |
template<typename Tp > | |
using | SharedFuture = std::shared_future<Tp> |
template<typename Tp > | |
using | Promise = std::promise<Tp> |
using | Mutex = std::mutex |
using | RecursiveMutex = std::recursive_mutex |
template<typename Tp > | |
using | EnvChoice = std::tuple<Tp, std::string, std::string> |
template<typename Tp > | |
using | EnvChoiceList = std::set<EnvChoice<Tp>> |
Functions | |
std::string | Demangle (const char *_str) |
std::string | Demangle (const std::string &_str) |
template<typename Tp > | |
std::string | Demangle () |
template<typename Tp , typename MutexTp = Mutex, size_t N = 4> | |
MutexTp & | TypeMutex (const unsigned int &_n=0) |
std::ostream & | operator<< (std::ostream &os, const Timer &t) |
template<typename... Args> | |
void | ConsumeParameters (Args &&...) |
template<typename Tp > | |
Tp | GetEnv (const std::string &env_id, Tp _default=Tp()) |
template<> | |
bool | GetEnv (const std::string &env_id, bool _default) |
template<typename Tp > | |
Tp | GetEnv (const std::string &env_id, Tp _default, const std::string &msg) |
template<typename Tp > | |
Tp | GetEnv (const std::string &env_id, const EnvChoiceList< Tp > &_choices, Tp _default) |
template<typename Tp > | |
Tp | GetChoice (const EnvChoiceList< Tp > &_choices, const std::string &str_var) |
void | PrintEnv (std::ostream &os=std::cout) |
Class Description:
This class provides a mechanism to create a mutex and locks/unlocks it. Can be used by applications to implement in a portable way a mutexing logic. Usage Example:
#include "Threading.hh" #include "AutoLock.hh" /// defined somewhere -- static so all threads see the same mutex static Mutex aMutex; /// somewhere else: /// The AutoLock instance will automatically unlock the mutex when it /// goes out of scope. One typically defines the scope within { } if /// there is thread-safe code following the auto-lock { AutoLock l(&aMutex); ProtectedCode(); } UnprotectedCode(); /// When ProtectedCode() is calling a function that also tries to lock /// a normal AutoLock + Mutex will "deadlock". In other words, the /// the mutex in the ProtectedCode() function will wait forever to /// acquire the lock that is being held by the function that called /// ProtectedCode(). In this situation, use a RecursiveAutoLock + /// RecursiveMutex, e.g. /// defined somewhere -- static so all threads see the same mutex static RecursiveMutex aRecursiveMutex; /// this function is sometimes called directly and sometimes called /// from SomeFunction_B(), which also locks the mutex void SomeFunction_A() { /// when called from SomeFunction_B(), a Mutex + AutoLock will /// deadlock RecursiveAutoLock l(&aRecursiveMutex); /// do something } void SomeFunction_B() { { RecursiveAutoLock l(&aRecursiveMutex); SomeFunction_A(); } UnprotectedCode(); }
Author: Andrea Dotti (15 Feb 2013): First Implementation
Update: Jonathan Madsen (9 Feb 2018): Replaced custom implementation with inheritance from C++11 unique_lock, which inherits the following member functions:
Note that AutoLock is defined also for a sequential Tasking build but below regarding implementation (also found in Threading.hh)
NOTE ON Tasking SERIAL BUILDS AND MUTEX/UNIQUE_LOCK ==================================================
Mutex and RecursiveMutex are always C++11 std::mutex types however, in serial mode, using MUTEXLOCK and MUTEXUNLOCK on these types has no effect – i.e. the mutexes are not actually locked or unlocked
Additionally, when a Mutex or RecursiveMutex is used with AutoLock and RecursiveAutoLock, respectively, these classes also suppressing the locking and unlocking of the mutex. Regardless of the build type, AutoLock and RecursiveAutoLock inherit from std::unique_lock<std::mutex> and std::unique_lock<std::recursive_mutex>, respectively. This means that in situations (such as is needed by the analysis category), the AutoLock and RecursiveAutoLock can be passed to functions requesting a std::unique_lock. Within these functions, since std::unique_lock member functions are not virtual, they will not retain the dummy locking and unlocking behavior --> An example of this behavior can be found below
Jonathan R. Madsen (February 21, 2018)
using PTL::AutoLock = TemplateAutoLock<Mutex> |
Definition at line 479 of file AutoLock.hh.
using PTL::Condition = std::condition_variable |
Definition at line 43 of file Threading.hh.
using PTL::decay_t = typename std::decay<T>::type |
Definition at line 54 of file Globals.hh.
using PTL::enable_if_t = typename std::enable_if<B, T>::type |
Definition at line 57 of file Globals.hh.
using PTL::EnvChoice = std::tuple<Tp, std::string, std::string> |
Definition at line 50 of file Utility.hh.
using PTL::EnvChoiceList = std::set<EnvChoice<Tp>> |
Definition at line 55 of file Utility.hh.
using PTL::Future = std::future<Tp> |
Definition at line 50 of file Threading.hh.
using PTL::Mutex = std::mutex |
Definition at line 57 of file Threading.hh.
using PTL::NativeThread = std::thread::native_handle_type |
Definition at line 38 of file Threading.hh.
using PTL::Pid_t = std::thread::id |
Definition at line 40 of file Threading.hh.
using PTL::Promise = std::promise<Tp> |
Definition at line 54 of file Threading.hh.
Definition at line 480 of file AutoLock.hh.
using PTL::RecursiveMutex = std::recursive_mutex |
Definition at line 58 of file Threading.hh.
using PTL::ResultOf_t = typename std::result_of<FuncT(ArgTypes...)>::type |
Definition at line 81 of file Backtrace.hh.
using PTL::SharedFuture = std::shared_future<Tp> |
Definition at line 52 of file Threading.hh.
Definition at line 123 of file ThreadData.hh.
using PTL::tbb_task_arena_t = tbb::task_arena |
Definition at line 125 of file ThreadData.hh.
using PTL::tbb_task_group_t = tbb::task_group |
Definition at line 124 of file ThreadData.hh.
using PTL::TBBTaskGroup = TaskGroup<Tp, Arg> |
Definition at line 38 of file TBBTaskGroup.hh.
using PTL::Thread = std::thread |
Definition at line 37 of file Threading.hh.
using PTL::ThreadId = Thread::id |
Definition at line 46 of file Threading.hh.
void PTL::ConsumeParameters | ( | Args && | ... | ) |
Definition at line 44 of file Utility.hh.
Referenced by PTL::ThreadPool::set_default_use_cpu_affinity(), PTL::ThreadPool::set_use_tbb(), PTL::Threading::SetPinAffinity(), PTL::Threading::SetPinAffinity(), PTL::Threading::SetThreadPriority(), and PTL::Threading::SetThreadPriority().
|
inline |
|
inline |
Definition at line 109 of file Backtrace.hh.
|
inline |
Definition at line 126 of file Backtrace.hh.
Tp PTL::GetChoice | ( | const EnvChoiceList< Tp > & | _choices, |
const std::string & | str_var ) |
Definition at line 315 of file Utility.hh.
|
inline |
Definition at line 180 of file Utility.hh.
Tp PTL::GetEnv | ( | const std::string & | env_id, |
const EnvChoiceList< Tp > & | _choices, | ||
Tp | _default ) |
Definition at line 246 of file Utility.hh.
Tp PTL::GetEnv | ( | const std::string & | env_id, |
Tp | _default, | ||
const std::string & | msg ) |
Definition at line 212 of file Utility.hh.
Tp PTL::GetEnv | ( | const std::string & | env_id, |
Tp | _default = Tp() ) |
Definition at line 155 of file Utility.hh.
Referenced by PTL::TaskRunManager::TaskRunManager(), and PTL::UserTaskQueue::UserTaskQueue().
|
inline |
Definition at line 165 of file Timer.hh.
|
inline |
Definition at line 359 of file Utility.hh.
MutexTp & PTL::TypeMutex | ( | const unsigned int & | _n = 0 | ) |
Definition at line 74 of file Threading.hh.
Referenced by PTL::ThreadPool::add_thread_id(), PTL::ThreadPool::destroy_threadpool(), PTL::ThreadPool::get_thread_id(), PTL::ThreadPool::initialize_threadpool(), PTL::ThreadPool::set_affinity(), PTL::ThreadPool::set_priority(), PTL::ThreadPool::start_thread(), PTL::ThreadPool::ThreadPool(), and PTL::UserTaskQueue::UserTaskQueue().