Geant4-11
Namespaces | Data Structures | Typedefs | Functions
PTL Namespace Reference

Namespaces

namespace  api
 
namespace  internal
 
namespace  mpl
 
namespace  tbb
 
namespace  ThisThread
 
namespace  thread_pool
 
namespace  Threading
 

Data Structures

struct  Back
 
struct  Back< Types..., BackT >
 
struct  CTValue
 
class  EnvSettings
 
struct  ForEachTupleArg
 
struct  ForwardTupleAsArgs
 
struct  ForwardTupleAsArgs< 0 >
 
struct  Front
 
struct  Front< FrontT, Types... >
 
class  IsEmpty
 
class  IsEmpty< Tuple<> >
 
struct  JoinFunction
 
struct  JoinFunction< void, JoinArg >
 
struct  JoinFunction< void, void >
 
class  PackagedTask
 The task class is supplied to thread_pool. More...
 
class  PopFrontT
 
class  PopFrontT< std::tuple< Head, Tail... > >
 
class  PushBackT
 
class  PushBackT< Tuple< Elements... >, NewElement >
 
class  PushFrontT
 
class  PushFrontT< std::tuple< Types... >, Element >
 
struct  ScopeDestructor
 
class  Singleton
 Singleton object that allows a deleter class to be specified. More...
 
struct  SmallerThanT
 
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  TemplateAutoLock
 
class  ThreadData
 
class  ThreadPool
 
struct  transform_tuple
 
struct  transform_tuple< Head >
 
class  TransformT
 
class  TransformT< List, MetaFun, false >
 
class  TransformT< List, MetaFun, true >
 
class  TransformT< Tuple< Elements... >, MetaFun, false >
 
class  Tuple
 
class  Tuple< Head, Tail... >
 
class  Tuple<>
 
struct  tuple_subset
 
class  TupleElt
 
class  TupleElt< Height, Tp, false >
 
class  TupleElt< Height, Tp, true >
 
class  UserTaskQueue
 
struct  Valuelist
 
class  VTask
 VTask is the abstract class stored in thread_pool. More...
 
class  VUserTaskQueue
 

Typedefs

typedef TemplateAutoLock< MutexAutoLock
 
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< RecursiveMutexRecursiveAutoLock
 
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)
 

Detailed Description

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 Documentation

◆ AutoLock

Definition at line 483 of file AutoLock.hh.

◆ Condition

typedef std::condition_variable PTL::Condition

Definition at line 135 of file Threading.hh.

◆ decay_t

template<typename T >
using PTL::decay_t = typedef typename std::decay<T>::type

Definition at line 68 of file Globals.hh.

◆ enable_if_t

template<bool B, typename T = void>
using PTL::enable_if_t = typedef typename std::enable_if<B, T>::type

Definition at line 71 of file Globals.hh.

◆ EnvChoice

template<typename Tp >
using PTL::EnvChoice = typedef std::tuple<Tp, std::string, std::string>

Definition at line 50 of file Utility.hh.

◆ EnvChoiceList

template<typename Tp >
using PTL::EnvChoiceList = typedef std::set<EnvChoice<Tp> >

Definition at line 55 of file Utility.hh.

◆ Future

template<typename Tp >
using PTL::Future = typedef std::future<Tp>

Definition at line 47 of file Threading.hh.

◆ Mutex

typedef std::mutex PTL::Mutex

Definition at line 77 of file Threading.hh.

◆ NativeThread

typedef std::thread::native_handle_type PTL::NativeThread

Definition at line 129 of file Threading.hh.

◆ Pid_t

typedef std::thread::id PTL::Pid_t

Definition at line 132 of file Threading.hh.

◆ PopFront

template<typename List >
using PTL::PopFront = typedef typename PopFrontT<List>::Type

Definition at line 187 of file Tuple.hh.

◆ Promise

template<typename Tp >
using PTL::Promise = typedef std::promise<Tp>

Definition at line 51 of file Threading.hh.

◆ PushBack

template<typename List , typename NewElement >
using PTL::PushBack = typedef typename PushBackT<List, NewElement>::Type

Definition at line 174 of file Tuple.hh.

◆ PushFront

template<typename List , typename NewElement >
using PTL::PushFront = typedef typename PushFrontT<List, NewElement>::Type

Definition at line 200 of file Tuple.hh.

◆ RecursiveAutoLock

Definition at line 484 of file AutoLock.hh.

◆ RecursiveMutex

typedef std::recursive_mutex PTL::RecursiveMutex

Definition at line 78 of file Threading.hh.

◆ SharedFuture

template<typename Tp >
using PTL::SharedFuture = typedef std::shared_future<Tp>

Definition at line 49 of file Threading.hh.

◆ TAutoLock

template<typename Tp >
using PTL::TAutoLock = typedef TemplateAutoLock<Tp>

Definition at line 489 of file AutoLock.hh.

◆ tbb_global_control_t

Definition at line 119 of file ThreadData.hh.

◆ tbb_task_arena_t

Definition at line 121 of file ThreadData.hh.

◆ tbb_task_group_t

Definition at line 120 of file ThreadData.hh.

◆ TBBTaskGroup

template<typename Tp , typename Arg = Tp>
using PTL::TBBTaskGroup = typedef TaskGroup<Tp, Arg>

Definition at line 38 of file TBBTaskGroup.hh.

◆ Thread

typedef std::thread PTL::Thread

Definition at line 128 of file Threading.hh.

◆ thread_lock

typedef int(* PTL::thread_lock) (Mutex *)

Definition at line 108 of file Threading.hh.

◆ thread_unlock

typedef int(* PTL::thread_unlock) (Mutex *)

Definition at line 109 of file Threading.hh.

◆ ThreadFunArgType

typedef void* PTL::ThreadFunArgType

Definition at line 107 of file Threading.hh.

◆ ThreadFunReturnType

typedef void* PTL::ThreadFunReturnType

Definition at line 106 of file Threading.hh.

◆ ThreadId

typedef Thread::id PTL::ThreadId

Definition at line 139 of file Threading.hh.

◆ Transform

template<typename List , template< typename T > class MetaFun>
using PTL::Transform = typedef typename TransformT<List, MetaFun>::Type

Definition at line 253 of file Tuple.hh.

◆ TypeList

template<typename... Tp>
using PTL::TypeList = typedef Tuple<Tp...>

Definition at line 145 of file Tuple.hh.

Function Documentation

◆ apply()

template<typename Func , typename... Elements, unsigned N = sizeof...(Elements)>
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.

439{
440 return applyImpl(func, t, std::make_index_sequence<N>());
441}
auto applyImpl(Func func, std::tuple< Elements... > const &t, Valuelist< unsigned, Indices... >) -> decltype(func(std::get< Indices >(t)...))
Definition: Tuple.hh:429

References applyImpl().

Referenced by for_each_tuple_arg().

◆ applyImpl()

template<typename Func , typename... Elements, unsigned... Indices>
auto PTL::applyImpl ( Func  func,
std::tuple< Elements... > const &  t,
Valuelist< unsigned, Indices... >   
) -> decltype(func(std::get<Indices>(t)...))

Definition at line 429 of file Tuple.hh.

431{
432 return func(std::get<Indices>(t)...);
433}

Referenced by apply().

◆ ConsumeParameters()

template<typename... Args>
void PTL::ConsumeParameters ( Args...  )

Definition at line 44 of file Utility.hh.

45{}

Referenced by PTL::Threading::SetPinAffinity().

◆ ContainerToTuple()

template<std::size_t N, typename Container , typename Indices = std::make_index_sequence<N>>
auto PTL::ContainerToTuple ( const Container &  tasks)
inline

Definition at line 364 of file Tuple.hh.

365{
366 return ContainerToTuple_impl(tasks, Indices{});
367}
auto ContainerToTuple_impl(const Container &tasks, std::index_sequence< N... >)
Definition: Tuple.hh:354

References ContainerToTuple_impl().

◆ ContainerToTuple_impl()

template<typename Container , std::size_t... N>
auto PTL::ContainerToTuple_impl ( const Container &  tasks,
std::index_sequence< N... >   
)
inline

Definition at line 354 of file Tuple.hh.

355{
356 return std::make_tuple(tasks[N]...);
357}

Referenced by ContainerToTuple().

◆ for_each_tuple_arg()

template<typename Func , typename Tuple >
void PTL::for_each_tuple_arg ( Func &&  func,
Tuple &&  _tuple 
)

Definition at line 314 of file Tuple.hh.

315{
317 std::forward<Func>(func), std::forward<std::tuple>(_tuple));
318}
auto apply(Func func, std::tuple< Elements... > const &t) -> decltype(applyImpl(func, t, std::make_index_sequence< N >()))
Definition: Tuple.hh:437

References apply().

◆ get()

template<unsigned I, typename... Elements>
auto PTL::get ( Tuple< Elements... > &  t) -> decltype(get_height<sizeof...(Elements) - I - 1>(t))

◆ get_height()

template<unsigned H, typename T >
T & PTL::get_height ( TupleElt< H, T > &  te)

Definition at line 95 of file Tuple.hh.

96{
97 return te.get();
98}

◆ GetChoice()

template<typename Tp >
Tp PTL::GetChoice ( const EnvChoiceList< Tp > &  _choices,
const std::string  str_var 
)

Definition at line 315 of file Utility.hh.

316{
317 auto asupper = [](std::string var) {
318 for(auto& itr : var)
319 itr = toupper(itr);
320 return var;
321 };
322
323 std::string upp_var = asupper(str_var);
324 Tp var = Tp();
325 // check to see if string matches a choice
326 for(const auto& itr : _choices)
327 {
328 if(asupper(std::get<1>(itr)) == upp_var)
329 {
330 // record value defined by environment
331 return std::get<0>(itr);
332 }
333 }
334 std::istringstream iss(str_var);
335 iss >> var;
336 // check to see if string matches a choice
337 for(const auto& itr : _choices)
338 {
339 if(var == std::get<0>(itr))
340 {
341 // record value defined by environment
342 return var;
343 }
344 }
345 // the value set in env did not match any choices
346 std::stringstream ss;
347 ss << "\n### Environment setting error @ " << __FUNCTION__ << " (line " << __LINE__
348 << ")! Invalid selection \"" << str_var << "\". Valid choices are:\n";
349 for(const auto& itr : _choices)
350 ss << "\t\"" << std::get<0>(itr) << "\" or \"" << std::get<1>(itr) << "\" ("
351 << std::get<2>(itr) << ")\n";
352 std::cerr << ss.str() << std::endl;
353 abort();
354}

◆ GetEnv() [1/4]

template<>
bool PTL::GetEnv ( const std::string &  env_id,
bool  _default 
)
inline

Definition at line 180 of file Utility.hh.

181{
182 char* env_var = std::getenv(env_id.c_str());
183 if(env_var)
184 {
185 std::string var = std::string(env_var);
186 bool val = true;
187 if(var.find_first_not_of("0123456789") == std::string::npos)
188 val = (bool) atoi(var.c_str());
189 else
190 {
191 for(auto& itr : var)
192 itr = tolower(itr);
193 if(var == "off" || var == "false")
194 val = false;
195 }
196 // record value defined by environment
197 EnvSettings::GetInstance()->insert<bool>(env_id, val);
198 return val;
199 }
200 // record default value
201 EnvSettings::GetInstance()->insert<bool>(env_id, false);
202
203 // return default if not specified in environment
204 return _default;
205}
std::map< G4String, G4AttDef > * GetInstance(const G4String &storeKey, G4bool &isNew)

References PTL::EnvSettings::GetInstance(), and PTL::EnvSettings::insert().

◆ GetEnv() [2/4]

template<typename Tp >
Tp PTL::GetEnv ( const std::string &  env_id,
const EnvChoiceList< Tp > &  _choices,
Tp  _default 
)

Definition at line 246 of file Utility.hh.

247{
248 auto asupper = [](std::string var) {
249 for(auto& itr : var)
250 itr = toupper(itr);
251 return var;
252 };
253
254 char* env_var = std::getenv(env_id.c_str());
255 if(env_var)
256 {
257 std::string str_var = std::string(env_var);
258 std::string upp_var = asupper(str_var);
259 Tp var = Tp();
260 // check to see if string matches a choice
261 for(const auto& itr : _choices)
262 {
263 if(asupper(std::get<1>(itr)) == upp_var)
264 {
265 // record value defined by environment
266 EnvSettings::GetInstance()->insert(env_id, itr);
267 return std::get<0>(itr);
268 }
269 }
270 std::istringstream iss(str_var);
271 iss >> var;
272 // check to see if string matches a choice
273 for(const auto& itr : _choices)
274 {
275 if(var == std::get<0>(itr))
276 {
277 // record value defined by environment
278 EnvSettings::GetInstance()->insert(env_id, itr);
279 return var;
280 }
281 }
282 // the value set in env did not match any choices
283 std::stringstream ss;
284 ss << "\n### Environment setting error @ " << __FUNCTION__ << " (line "
285 << __LINE__ << ")! Invalid selection for \"" << env_id
286 << "\". Valid choices are:\n";
287 for(const auto& itr : _choices)
288 ss << "\t\"" << std::get<0>(itr) << "\" or \"" << std::get<1>(itr) << "\" ("
289 << std::get<2>(itr) << ")\n";
290 std::cerr << ss.str() << std::endl;
291 abort();
292 }
293
294 std::string _name = "???";
295 std::string _desc = "description not provided";
296 for(const auto& itr : _choices)
297 if(std::get<0>(itr) == _default)
298 {
299 _name = std::get<1>(itr);
300 _desc = std::get<2>(itr);
301 break;
302 }
303
304 // record default value
305 EnvSettings::GetInstance()->insert(env_id, EnvChoice<Tp>(_default, _name, _desc));
306
307 // return default if not specified in environment
308 return _default;
309}

References PTL::EnvSettings::GetInstance(), and PTL::EnvSettings::insert().

◆ GetEnv() [3/4]

template<typename Tp >
Tp PTL::GetEnv ( const std::string &  env_id,
Tp  _default,
const std::string &  msg 
)

Definition at line 212 of file Utility.hh.

213{
214 char* env_var = std::getenv(env_id.c_str());
215 if(env_var)
216 {
217 std::string str_var = std::string(env_var);
218 std::istringstream iss(str_var);
219 Tp var = Tp();
220 iss >> var;
221 std::cout << "Environment variable \"" << env_id << "\" enabled with "
222 << "value == " << var << ". " << msg << std::endl;
223 // record value defined by environment
224 EnvSettings::GetInstance()->insert<Tp>(env_id, var);
225 return var;
226 }
227 // record default value
228 EnvSettings::GetInstance()->insert<Tp>(env_id, _default);
229
230 // return default if not specified in environment
231 return _default;
232}

References PTL::EnvSettings::GetInstance(), and PTL::EnvSettings::insert().

◆ GetEnv() [4/4]

template<typename Tp >
Tp PTL::GetEnv ( const std::string &  env_id,
Tp  _default = Tp() 
)

Definition at line 155 of file Utility.hh.

156{
157 char* env_var = std::getenv(env_id.c_str());
158 if(env_var)
159 {
160 std::string str_var = std::string(env_var);
161 std::istringstream iss(str_var);
162 Tp var = Tp();
163 iss >> var;
164 // record value defined by environment
165 EnvSettings::GetInstance()->insert<Tp>(env_id, var);
166 return var;
167 }
168 // record default value
169 EnvSettings::GetInstance()->insert<Tp>(env_id, _default);
170
171 // return default if not specified in environment
172 return _default;
173}

References PTL::EnvSettings::GetInstance(), and PTL::EnvSettings::insert().

◆ GetSharedPointerPair()

template<typename Tp , typename Tag = api::native, typename Ptr = std::shared_ptr<Tp>, typename Pair = std::pair<Ptr, Ptr>>
Pair & PTL::GetSharedPointerPair ( )

Definition at line 89 of file Types.hh.

90{
91 static auto _master = std::make_shared<Tp>();
92 static std::atomic<int64_t> _count(0);
93 static thread_local auto _inst =
94 Pair(_master, Ptr((_count++ == 0) ? nullptr : new Tp()));
95 return _inst;
96}

◆ GetSharedPointerPairInstance()

template<typename Tp , typename Tag = api::native, typename Ptr = std::shared_ptr<Tp>, typename Pair = std::pair<Ptr, Ptr>>
Ptr PTL::GetSharedPointerPairInstance ( )

Definition at line 103 of file Types.hh.

104{
105 static thread_local auto& _pinst = GetSharedPointerPair<Tp, Tag>();
106 static thread_local auto& _inst = _pinst.second.get() ? _pinst.second : _pinst.first;
107 return _inst;
108}

◆ GetSharedPointerPairMasterInstance()

template<typename Tp , typename Tag = api::native, typename Ptr = std::shared_ptr<Tp>, typename Pair = std::pair<Ptr, Ptr>>
Ptr PTL::GetSharedPointerPairMasterInstance ( )

Definition at line 115 of file Types.hh.

116{
117 static auto& _pinst = GetSharedPointerPair<Tp, Tag>();
118 static auto _inst = _pinst.first;
119 return _inst;
120}

◆ InvokeSequence()

template<typename Func , typename Tuple , std::size_t N = std::tuple_size<Tuple>::value, typename Indices = std::make_index_sequence<N>>
auto PTL::InvokeSequence ( const Func &  func,
const Tuple data 
)
inline

Definition at line 344 of file Tuple.hh.

345{
346 return InvokeSequence_impl(func, data);
347}
auto InvokeSequence_impl(const Func &func, const Tuple &data)
Definition: Tuple.hh:333

References InvokeSequence_impl().

◆ InvokeSequence_impl() [1/2]

template<typename Func , typename Tuple , std::size_t Head>
auto PTL::InvokeSequence_impl ( const Func &  func,
const Tuple data 
)
inline

Definition at line 324 of file Tuple.hh.

325{
326 func(std::get<Head>(data));
327}

Referenced by InvokeSequence(), and InvokeSequence_impl().

◆ InvokeSequence_impl() [2/2]

template<typename Func , typename Tuple , std::size_t Head, std::size_t... Tail>
auto PTL::InvokeSequence_impl ( const Func &  func,
const Tuple data 
)
inline

Definition at line 333 of file Tuple.hh.

334{
335 func(std::get<Head>(data));
336 InvokeSequence_impl<Func, Tuple, Tail...>(func, data);
337}

References InvokeSequence_impl().

◆ PrintEnv()

void PTL::PrintEnv ( std::ostream &  os = std::cout)
inline

Definition at line 359 of file Utility.hh.

360{
361 os << (*EnvSettings::GetInstance());
362}

References PTL::EnvSettings::GetInstance().

◆ pushFront()

template<typename... Types, typename V >
PushFront< std::tuple< Types... >, V > PTL::pushFront ( std::tuple< Types... > const &  tuple,
V const &  value 
)

Definition at line 204 of file Tuple.hh.

205{
206 return PushFront<std::tuple<Types...>, V>(value, tuple);
207}
typename PushFrontT< List, NewElement >::Type PushFront
Definition: Tuple.hh:200

◆ tuple_transform() [1/2]

template<typename Head >
void PTL::tuple_transform ( const std::function< void(const Head &)> &  pred,
const std::tuple< Head > &  data 
)
inline

Definition at line 385 of file Tuple.hh.

387{
388 pred(std::get<0>(data));
389}

Referenced by tuple_transform().

◆ tuple_transform() [2/2]

template<typename Head , typename... Tail>
void PTL::tuple_transform ( const std::function< void(const Head &)> &  pred,
const std::tuple< Head, Tail... > &  data 
)
inline

Definition at line 393 of file Tuple.hh.

395{
396 pred(std::get<0>(data));
397 auto subset = tuple_subset<Head, Tail...>::template get<Tail...>(data);
398 tuple_transform<Tail...>(pred, std::forward<decltype(subset)>(subset));
399}
auto get(Tuple< Elements... > &t) -> decltype(get_height< sizeof...(Elements) - I - 1 >(t))
Definition: Tuple.hh:139
void tuple_transform(const std::function< void(const Head &)> &pred, const std::tuple< Head, Tail... > &data)
Definition: Tuple.hh:393

References get(), and tuple_transform().

◆ TypeMutex()

template<typename Tp , typename MutexTp = Mutex, size_t N = 4>
MutexTp & PTL::TypeMutex ( const unsigned int &  _n = 0)

Definition at line 119 of file Threading.hh.

120{
121 static std::array<MutexTp, N> _mutex_array{};
122 return _mutex_array[_n % N];
123}

Referenced by PTL::UserTaskQueue::UserTaskQueue().