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

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

#include <Task.hh>

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

Public Types

typedef Task< RetT > this_type
 
typedef std::promise< RetT > promise_type
 
typedef std::future< RetT > future_type
 
typedef std::packaged_task< RetT()> packaged_task_type
 
typedef RetT result_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)
 
template<typename FuncT >
 Task (VTaskGroup *tg, FuncT &&func)
 
template<typename FuncT >
 Task (ThreadPool *tp, FuncT &&func)
 
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>
class PTL::Task< RetT, void >

The task class is supplied to thread_pool.

Definition at line 162 of file Task.hh.

Member Typedef Documentation

◆ future_type

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

Definition at line 167 of file Task.hh.

◆ packaged_task_type

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

Definition at line 168 of file Task.hh.

◆ promise_type

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

Definition at line 166 of file Task.hh.

◆ result_type

template<typename RetT >
typedef RetT PTL::Task< RetT, void >::result_type

Definition at line 169 of file Task.hh.

◆ this_type

template<typename RetT >
typedef Task<RetT> PTL::Task< RetT, void >::this_type

Definition at line 165 of file Task.hh.

Constructor & Destructor Documentation

◆ Task() [1/3]

template<typename RetT >
template<typename FuncT >
PTL::Task< RetT, void >::Task ( FuncT &&  func)
inline

Definition at line 173 of file Task.hh.

174 : VTask()
175 , m_ptask(std::forward<FuncT>(func))
176 {}
VTask()
Definition: VTask.cc:40

◆ Task() [2/3]

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

Definition at line 179 of file Task.hh.

180 : VTask(tg)
181 , m_ptask(std::forward<FuncT>(func))
182 {}

◆ Task() [3/3]

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

Definition at line 185 of file Task.hh.

186 : VTask(tp)
187 , m_ptask(std::forward<FuncT>(func))
188 {}

◆ ~Task()

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

Definition at line 190 of file Task.hh.

190{}

Member Function Documentation

◆ get_future()

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

Definition at line 206 of file Task.hh.

206{ return m_ptask.get_future(); }

◆ is_native_task()

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

Reimplemented from PTL::VTask.

Definition at line 205 of file Task.hh.

205{ return true; }

◆ operator()()

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

Implements PTL::VTask.

Definition at line 194 of file Task.hh.

195 {
196 m_ptask();
197 // decrements the task-group counter on active tasks
198 // when the counter is < 2, if the thread owning the task group is
199 // sleeping at the TaskGroup::wait(), it signals the thread to wake
200 // up and check if all tasks are finished, proceeding if this
201 // check returns as true
203 }
void operator--()
Definition: VTask.cc:69

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