Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
PTL::Task< RetT, Args > Class Template Reference

The task class is supplied to thread_pool. More...

#include <Task.hh>

+ Inheritance diagram for PTL::Task< RetT, Args >:

Public Types

typedef Task< RetT, Args... > this_type
 
typedef std::promise< RetT > promise_type
 
typedef std::future< RetT > future_type
 
typedef std::packaged_task< RetT(Args...)> packaged_task_type
 
typedef RetT result_type
 
typedef std::tuple< Args... > tuple_type
 
- Public Types inherited from PTL::VTask
typedef std::thread::id tid_type
 
typedef size_t size_type
 
typedef VTask this_type
 
typedef std::atomic_uintmax_t count_t
 
typedef VTaskiterator
 
typedef const VTaskconst_iterator
 
typedef std::function< void()> void_func_t
 

Public Member Functions

template<typename FuncT >
 Task (FuncT &&func, Args... args)
 
template<typename FuncT >
 Task (VTaskGroup *tg, FuncT &&func, Args... args)
 
template<typename FuncT >
 Task (ThreadPool *tp, FuncT &&func, Args... args)
 
virtual ~Task ()
 
virtual void operator() () final
 
virtual bool is_native_task () const override
 
future_type get_future ()
 
- Public Member Functions inherited from PTL::VTask
 VTask ()
 
 VTask (VTaskGroup *task_group)
 
 VTask (ThreadPool *pool)
 
virtual ~VTask ()
 
virtual void operator() ()=0
 
void operator-- ()
 
virtual bool is_native_task () const
 
virtual ThreadPoolpool () const
 
VTaskGroupgroup () const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
intmax_t & depth ()
 
const intmax_t & depth () const
 

Additional Inherited Members

- Static Protected Member Functions inherited from PTL::VTask
static tid_type this_tid ()
 
- Protected Attributes inherited from PTL::VTask
intmax_t m_depth
 
VTaskGroupm_group
 
ThreadPoolm_pool
 
void_func_t m_func = []() {}
 

Detailed Description

template<typename RetT, typename... Args>
class PTL::Task< RetT, Args >

The task class is supplied to thread_pool.

Definition at line 103 of file Task.hh.

Member Typedef Documentation

◆ future_type

template<typename RetT , typename... Args>
typedef std::future<RetT> PTL::Task< RetT, Args >::future_type

Definition at line 108 of file Task.hh.

◆ packaged_task_type

template<typename RetT , typename... Args>
typedef std::packaged_task<RetT(Args...)> PTL::Task< RetT, Args >::packaged_task_type

Definition at line 109 of file Task.hh.

◆ promise_type

template<typename RetT , typename... Args>
typedef std::promise<RetT> PTL::Task< RetT, Args >::promise_type

Definition at line 107 of file Task.hh.

◆ result_type

template<typename RetT , typename... Args>
typedef RetT PTL::Task< RetT, Args >::result_type

Definition at line 110 of file Task.hh.

◆ this_type

template<typename RetT , typename... Args>
typedef Task<RetT, Args...> PTL::Task< RetT, Args >::this_type

Definition at line 106 of file Task.hh.

◆ tuple_type

template<typename RetT , typename... Args>
typedef std::tuple<Args...> PTL::Task< RetT, Args >::tuple_type

Definition at line 111 of file Task.hh.

Constructor & Destructor Documentation

◆ Task() [1/3]

template<typename RetT , typename... Args>
template<typename FuncT >
PTL::Task< RetT, Args >::Task ( FuncT &&  func,
Args...  args 
)
inline

Definition at line 115 of file Task.hh.

116 : VTask()
117 , m_ptask(std::forward<FuncT>(func))
118 , m_args(args...)
119 {}
VTask()
Definition: VTask.cc:40

◆ Task() [2/3]

template<typename RetT , typename... Args>
template<typename FuncT >
PTL::Task< RetT, Args >::Task ( VTaskGroup tg,
FuncT &&  func,
Args...  args 
)
inline

Definition at line 122 of file Task.hh.

123 : VTask(tg)
124 , m_ptask(std::forward<FuncT>(func))
125 , m_args(args...)
126 {}

◆ Task() [3/3]

template<typename RetT , typename... Args>
template<typename FuncT >
PTL::Task< RetT, Args >::Task ( ThreadPool tp,
FuncT &&  func,
Args...  args 
)
inline

Definition at line 129 of file Task.hh.

130 : VTask(tp)
131 , m_ptask(std::forward<FuncT>(func))
132 , m_args(args...)
133 {}

◆ ~Task()

template<typename RetT , typename... Args>
virtual PTL::Task< RetT, Args >::~Task ( )
inlinevirtual

Definition at line 135 of file Task.hh.

135{}

Member Function Documentation

◆ get_future()

template<typename RetT , typename... Args>
future_type PTL::Task< RetT, Args >::get_future ( )
inline

Definition at line 151 of file Task.hh.

151{ return m_ptask.get_future(); }

◆ is_native_task()

template<typename RetT , typename... Args>
virtual bool PTL::Task< RetT, Args >::is_native_task ( ) const
inlineoverridevirtual

Reimplemented from PTL::VTask.

Definition at line 150 of file Task.hh.

150{ return true; }

◆ operator()()

template<typename RetT , typename... Args>
virtual void PTL::Task< RetT, Args >::operator() ( )
inlinefinalvirtual

Implements PTL::VTask.

Definition at line 139 of file Task.hh.

140 {
141 mpl::apply(std::move(m_ptask), std::move(m_args));
142 // decrements the task-group counter on active tasks
143 // when the counter is < 2, if the thread owning the task group is
144 // sleeping at the TaskGroup::wait(), it signals the thread to wake
145 // up and check if all tasks are finished, proceeding if this
146 // check returns as true
148 }
void operator--()
Definition: VTask.cc:69

The documentation for this class was generated from the following file: