Geant4-11
|
Namespaces | |
namespace | api |
namespace | internal |
namespace | mpl |
namespace | tbb |
namespace | ThisThread |
namespace | thread_pool |
namespace | Threading |
Typedefs | |
typedef TemplateAutoLock< Mutex > | AutoLock |
typedef std::condition_variable | Condition |
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 > | |
using | EnvChoice = std::tuple< Tp, std::string, std::string > |
template<typename Tp > | |
using | EnvChoiceList = std::set< EnvChoice< Tp > > |
template<typename Tp > | |
using | Future = std::future< Tp > |
typedef std::mutex | Mutex |
typedef std::thread::native_handle_type | NativeThread |
typedef std::thread::id | Pid_t |
template<typename List > | |
using | PopFront = typename PopFrontT< List >::Type |
template<typename Tp > | |
using | Promise = std::promise< Tp > |
template<typename List , typename NewElement > | |
using | PushBack = typename PushBackT< List, NewElement >::Type |
template<typename List , typename NewElement > | |
using | PushFront = typename PushFrontT< List, NewElement >::Type |
typedef TemplateAutoLock< RecursiveMutex > | RecursiveAutoLock |
typedef std::recursive_mutex | RecursiveMutex |
template<typename Tp > | |
using | SharedFuture = std::shared_future< Tp > |
template<typename Tp > | |
using | TAutoLock = TemplateAutoLock< Tp > |
using | tbb_global_control_t = tbb::global_control |
using | tbb_task_arena_t = tbb::task_arena |
using | tbb_task_group_t = tbb::task_group |
template<typename Tp , typename Arg = Tp> | |
using | TBBTaskGroup = TaskGroup< Tp, Arg > |
typedef std::thread | Thread |
typedef int(* | thread_lock) (Mutex *) |
typedef int(* | thread_unlock) (Mutex *) |
typedef void * | ThreadFunArgType |
typedef void * | ThreadFunReturnType |
typedef Thread::id | ThreadId |
template<typename List , template< typename T > class MetaFun> | |
using | Transform = typename TransformT< List, MetaFun >::Type |
template<typename... Tp> | |
using | TypeList = Tuple< Tp... > |
Functions | |
template<typename Func , typename... Elements, unsigned N = sizeof...(Elements)> | |
auto | apply (Func func, std::tuple< Elements... > const &t) -> decltype(applyImpl(func, t, std::make_index_sequence< N >())) |
template<typename Func , typename... Elements, unsigned... Indices> | |
auto | applyImpl (Func func, std::tuple< Elements... > const &t, Valuelist< unsigned, Indices... >) -> decltype(func(std::get< Indices >(t)...)) |
template<typename... Args> | |
void | ConsumeParameters (Args...) |
template<std::size_t N, typename Container , typename Indices = std::make_index_sequence<N>> | |
auto | ContainerToTuple (const Container &tasks) |
template<typename Container , std::size_t... N> | |
auto | ContainerToTuple_impl (const Container &tasks, std::index_sequence< N... >) |
template<typename Func , typename Tuple > | |
void | for_each_tuple_arg (Func &&func, Tuple &&_tuple) |
template<unsigned I, typename... Elements> | |
auto | get (Tuple< Elements... > &t) -> decltype(get_height< sizeof...(Elements) - I - 1 >(t)) |
template<unsigned H, typename T > | |
T & | get_height (TupleElt< H, T > &te) |
template<typename Tp > | |
Tp | GetChoice (const EnvChoiceList< Tp > &_choices, const std::string str_var) |
template<> | |
bool | GetEnv (const std::string &env_id, bool _default) |
template<typename Tp > | |
Tp | GetEnv (const std::string &env_id, const EnvChoiceList< Tp > &_choices, Tp _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, Tp _default=Tp()) |
template<typename Tp , typename Tag = api::native, typename Ptr = std::shared_ptr<Tp>, typename Pair = std::pair<Ptr, Ptr>> | |
Pair & | GetSharedPointerPair () |
template<typename Tp , typename Tag = api::native, typename Ptr = std::shared_ptr<Tp>, typename Pair = std::pair<Ptr, Ptr>> | |
Ptr | GetSharedPointerPairInstance () |
template<typename Tp , typename Tag = api::native, typename Ptr = std::shared_ptr<Tp>, typename Pair = std::pair<Ptr, Ptr>> | |
Ptr | GetSharedPointerPairMasterInstance () |
template<typename Func , typename Tuple , std::size_t N = std::tuple_size<Tuple>::value, typename Indices = std::make_index_sequence<N>> | |
auto | InvokeSequence (const Func &func, const Tuple &data) |
template<typename Func , typename Tuple , std::size_t Head> | |
auto | InvokeSequence_impl (const Func &func, const Tuple &data) |
template<typename Func , typename Tuple , std::size_t Head, std::size_t... Tail> | |
auto | InvokeSequence_impl (const Func &func, const Tuple &data) |
void | PrintEnv (std::ostream &os=std::cout) |
template<typename... Types, typename V > | |
PushFront< std::tuple< Types... >, V > | pushFront (std::tuple< Types... > const &tuple, V const &value) |
template<typename Head > | |
void | tuple_transform (const std::function< void(const Head &)> &pred, const std::tuple< Head > &data) |
template<typename Head , typename... Tail> | |
void | tuple_transform (const std::function< void(const Head &)> &pred, const std::tuple< Head, Tail... > &data) |
template<typename Tp , typename MutexTp = Mutex, size_t N = 4> | |
MutexTp & | TypeMutex (const unsigned int &_n=0) |
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)
typedef TemplateAutoLock<Mutex> PTL::AutoLock |
Definition at line 483 of file AutoLock.hh.
typedef std::condition_variable PTL::Condition |
Definition at line 135 of file Threading.hh.
using PTL::decay_t = typedef typename std::decay<T>::type |
Definition at line 68 of file Globals.hh.
using PTL::enable_if_t = typedef typename std::enable_if<B, T>::type |
Definition at line 71 of file Globals.hh.
using PTL::EnvChoice = typedef std::tuple<Tp, std::string, std::string> |
Definition at line 50 of file Utility.hh.
using PTL::EnvChoiceList = typedef std::set<EnvChoice<Tp> > |
Definition at line 55 of file Utility.hh.
using PTL::Future = typedef std::future<Tp> |
Definition at line 47 of file Threading.hh.
typedef std::mutex PTL::Mutex |
Definition at line 77 of file Threading.hh.
typedef std::thread::native_handle_type PTL::NativeThread |
Definition at line 129 of file Threading.hh.
typedef std::thread::id PTL::Pid_t |
Definition at line 132 of file Threading.hh.
using PTL::PopFront = typedef typename PopFrontT<List>::Type |
using PTL::Promise = typedef std::promise<Tp> |
Definition at line 51 of file Threading.hh.
using PTL::PushBack = typedef typename PushBackT<List, NewElement>::Type |
using PTL::PushFront = typedef typename PushFrontT<List, NewElement>::Type |
Definition at line 484 of file AutoLock.hh.
typedef std::recursive_mutex PTL::RecursiveMutex |
Definition at line 78 of file Threading.hh.
using PTL::SharedFuture = typedef std::shared_future<Tp> |
Definition at line 49 of file Threading.hh.
using PTL::TAutoLock = typedef TemplateAutoLock<Tp> |
Definition at line 489 of file AutoLock.hh.
using PTL::tbb_global_control_t = typedef tbb::global_control |
Definition at line 119 of file ThreadData.hh.
using PTL::tbb_task_arena_t = typedef tbb::task_arena |
Definition at line 121 of file ThreadData.hh.
using PTL::tbb_task_group_t = typedef tbb::task_group |
Definition at line 120 of file ThreadData.hh.
using PTL::TBBTaskGroup = typedef TaskGroup<Tp, Arg> |
Definition at line 38 of file TBBTaskGroup.hh.
typedef std::thread PTL::Thread |
Definition at line 128 of file Threading.hh.
typedef int(* PTL::thread_lock) (Mutex *) |
Definition at line 108 of file Threading.hh.
typedef int(* PTL::thread_unlock) (Mutex *) |
Definition at line 109 of file Threading.hh.
typedef void* PTL::ThreadFunArgType |
Definition at line 107 of file Threading.hh.
typedef void* PTL::ThreadFunReturnType |
Definition at line 106 of file Threading.hh.
typedef Thread::id PTL::ThreadId |
Definition at line 139 of file Threading.hh.
using PTL::Transform = typedef typename TransformT<List, MetaFun>::Type |
using PTL::TypeList = typedef Tuple<Tp...> |
auto PTL::apply | ( | Func | func, |
std::tuple< Elements... > const & | t | ||
) | -> decltype(applyImpl(func, t, std::make_index_sequence<N>())) |
Definition at line 437 of file Tuple.hh.
References applyImpl().
Referenced by for_each_tuple_arg().
auto PTL::applyImpl | ( | Func | func, |
std::tuple< Elements... > const & | t, | ||
Valuelist< unsigned, Indices... > | |||
) | -> decltype(func(std::get<Indices>(t)...)) |
void PTL::ConsumeParameters | ( | Args... | ) |
|
inline |
Definition at line 364 of file Tuple.hh.
References ContainerToTuple_impl().
|
inline |
Definition at line 354 of file Tuple.hh.
Referenced by ContainerToTuple().
void PTL::for_each_tuple_arg | ( | Func && | func, |
Tuple && | _tuple | ||
) |
Definition at line 314 of file Tuple.hh.
References apply().
auto PTL::get | ( | Tuple< Elements... > & | t | ) | -> decltype(get_height<sizeof...(Elements) - I - 1>(t)) |
Definition at line 139 of file Tuple.hh.
Referenced by demo.App::cmd_beamOn(), testem0.App::cmd_beamOn(), Lesson1.App::cmd_beamOn(), ExN03.App::cmd_beamOn(), demo.App::cmd_g4command(), Lesson1.App::cmd_g4command(), ExN03.App::cmd_g4command(), demo.App::cmd_pan(), ExN03.App::cmd_pan(), demo.App::cmd_setProcess(), ExN03.App::cmd_setProcess(), demo.App::cmd_viewer(), ExN03.App::cmd_viewer(), PTL::Singleton< Type, PointerT >::Destroy(), PTL::Singleton< Type, PointerT >::GetInstance(), SoImageWriter::GLRender(), gz_load(), PTL::Tuple< Head, Tail... >::head(), G4TaskRunManagerKernel::InitializeWorker(), PTL::Singleton< Type, PointerT >::Reset(), G4TaskRunManagerKernel::TerminateWorker(), G4TaskRunManagerKernel::TerminateWorkerRunEventLoop(), and tuple_transform().
T & PTL::get_height | ( | TupleElt< H, T > & | te | ) |
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.
References PTL::EnvSettings::GetInstance(), and PTL::EnvSettings::insert().
Tp PTL::GetEnv | ( | const std::string & | env_id, |
const EnvChoiceList< Tp > & | _choices, | ||
Tp | _default | ||
) |
Definition at line 246 of file Utility.hh.
References PTL::EnvSettings::GetInstance(), and PTL::EnvSettings::insert().
Tp PTL::GetEnv | ( | const std::string & | env_id, |
Tp | _default, | ||
const std::string & | msg | ||
) |
Definition at line 212 of file Utility.hh.
References PTL::EnvSettings::GetInstance(), and PTL::EnvSettings::insert().
Tp PTL::GetEnv | ( | const std::string & | env_id, |
Tp | _default = Tp() |
||
) |
Definition at line 155 of file Utility.hh.
References PTL::EnvSettings::GetInstance(), and PTL::EnvSettings::insert().
Pair & PTL::GetSharedPointerPair | ( | ) |
Ptr PTL::GetSharedPointerPairInstance | ( | ) |
Ptr PTL::GetSharedPointerPairMasterInstance | ( | ) |
|
inline |
Definition at line 344 of file Tuple.hh.
References InvokeSequence_impl().
|
inline |
Definition at line 324 of file Tuple.hh.
Referenced by InvokeSequence(), and InvokeSequence_impl().
|
inline |
Definition at line 333 of file Tuple.hh.
References InvokeSequence_impl().
|
inline |
Definition at line 359 of file Utility.hh.
References PTL::EnvSettings::GetInstance().
PushFront< std::tuple< Types... >, V > PTL::pushFront | ( | std::tuple< Types... > const & | tuple, |
V const & | value | ||
) |
|
inline |
Definition at line 385 of file Tuple.hh.
Referenced by tuple_transform().
|
inline |
Definition at line 393 of file Tuple.hh.
References get(), and tuple_transform().
MutexTp & PTL::TypeMutex | ( | const unsigned int & | _n = 0 | ) |
Definition at line 119 of file Threading.hh.
Referenced by PTL::UserTaskQueue::UserTaskQueue().