Geant4-11
Public Types | Public Member Functions | Protected Attributes | Private Attributes
PTL::PackagedTask< RetT, Args > Class Template Reference

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

#include <Task.hh>

Inheritance diagram for PTL::PackagedTask< RetT, Args >:
PTL::TaskFuture< RetT > PTL::VTask

Public Types

typedef std::future< RetT > future_type
 
typedef std::packaged_task< RetT(Args...)> packaged_task_type
 
typedef std::promise< RetT > promise_type
 
typedef RetT result_type
 
typedef size_t size_type
 
typedef PackagedTask< RetT, Args... > this_type
 
typedef std::thread::id tid_type
 
typedef std::tuple< Args... > tuple_type
 
typedef std::function< void()> void_func_t
 

Public Member Functions

intmax_t depth () const
 
virtual RetT get () final
 
virtual future_type get_future () final
 
bool is_native_task () const
 
virtual void operator() () final
 
PackagedTaskoperator= (const PackagedTask &)=delete
 
PackagedTaskoperator= (PackagedTask &&)=default
 
template<typename FuncT >
 PackagedTask (bool _is_native, intmax_t _depth, FuncT func, Args... args)
 
 PackagedTask (const PackagedTask &)=delete
 
template<typename FuncT >
 PackagedTask (FuncT func, Args... args)
 
 PackagedTask (PackagedTask &&)=default
 
virtual void wait () final
 
virtual ~PackagedTask ()=default
 

Protected Attributes

intmax_t m_depth = 0
 
void_func_t m_func = []() {}
 
bool m_is_native = false
 

Private Attributes

tuple_type m_args
 
packaged_task_type m_ptask
 

Detailed Description

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

The task class is supplied to thread_pool.

Definition at line 81 of file Task.hh.

Member Typedef Documentation

◆ future_type

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

Definition at line 86 of file Task.hh.

◆ packaged_task_type

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

Definition at line 87 of file Task.hh.

◆ promise_type

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

Definition at line 85 of file Task.hh.

◆ result_type

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

Definition at line 88 of file Task.hh.

◆ size_type

typedef size_t PTL::VTask::size_type
inherited

Definition at line 57 of file VTask.hh.

◆ this_type

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

Definition at line 84 of file Task.hh.

◆ tid_type

typedef std::thread::id PTL::VTask::tid_type
inherited

Definition at line 56 of file VTask.hh.

◆ tuple_type

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

Definition at line 89 of file Task.hh.

◆ void_func_t

typedef std::function<void()> PTL::VTask::void_func_t
inherited

Definition at line 58 of file VTask.hh.

Constructor & Destructor Documentation

◆ PackagedTask() [1/4]

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

Definition at line 94 of file Task.hh.

95 : TaskFuture<RetT>{ true, 0 }
96 , m_ptask{ std::move(func) }
97 , m_args{ args... }
98 {}
static char ** args
Definition: G4Xt.cc:51
tuple_type m_args
Definition: Task.hh:124
packaged_task_type m_ptask
Definition: Task.hh:123

◆ PackagedTask() [2/4]

template<typename RetT , typename... Args>
template<typename FuncT >
PTL::PackagedTask< RetT, Args >::PackagedTask ( bool  _is_native,
intmax_t  _depth,
FuncT  func,
Args...  args 
)
inline

Definition at line 101 of file Task.hh.

102 : TaskFuture<RetT>{ _is_native, _depth }
103 , m_ptask{ std::move(func) }
104 , m_args{ args... }
105 {}

◆ ~PackagedTask()

template<typename RetT , typename... Args>
virtual PTL::PackagedTask< RetT, Args >::~PackagedTask ( )
virtualdefault

◆ PackagedTask() [3/4]

template<typename RetT , typename... Args>
PTL::PackagedTask< RetT, Args >::PackagedTask ( const PackagedTask< RetT, Args > &  )
delete

◆ PackagedTask() [4/4]

template<typename RetT , typename... Args>
PTL::PackagedTask< RetT, Args >::PackagedTask ( PackagedTask< RetT, Args > &&  )
default

Member Function Documentation

◆ depth()

intmax_t PTL::VTask::depth ( ) const
inlineinherited

Definition at line 78 of file VTask.hh.

78{ return m_depth; }
intmax_t m_depth
Definition: VTask.hh:82

References PTL::VTask::m_depth.

◆ get()

template<typename RetT , typename... Args>
virtual RetT PTL::PackagedTask< RetT, Args >::get ( )
inlinefinalvirtual

Implements PTL::TaskFuture< RetT >.

Definition at line 120 of file Task.hh.

120{ return m_ptask.get_future().get(); }

References PTL::PackagedTask< RetT, Args >::m_ptask.

◆ get_future()

template<typename RetT , typename... Args>
virtual future_type PTL::PackagedTask< RetT, Args >::get_future ( )
inlinefinalvirtual

Implements PTL::TaskFuture< RetT >.

Definition at line 118 of file Task.hh.

118{ return m_ptask.get_future(); }

References PTL::PackagedTask< RetT, Args >::m_ptask.

◆ is_native_task()

bool PTL::VTask::is_native_task ( ) const
inlineinherited

Definition at line 77 of file VTask.hh.

77{ return m_is_native; }
bool m_is_native
Definition: VTask.hh:81

References PTL::VTask::m_is_native.

◆ operator()()

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

Implements PTL::VTask.

Definition at line 117 of file Task.hh.

117{ mpl::apply(std::move(m_ptask), std::move(m_args)); }
static void apply(FnT &&_func, TupleT &&_args)
Definition: Globals.hh:196

References PTL::mpl::apply(), PTL::PackagedTask< RetT, Args >::m_args, and PTL::PackagedTask< RetT, Args >::m_ptask.

◆ operator=() [1/2]

template<typename RetT , typename... Args>
PackagedTask & PTL::PackagedTask< RetT, Args >::operator= ( const PackagedTask< RetT, Args > &  )
delete

◆ operator=() [2/2]

template<typename RetT , typename... Args>
PackagedTask & PTL::PackagedTask< RetT, Args >::operator= ( PackagedTask< RetT, Args > &&  )
default

◆ wait()

template<typename RetT , typename... Args>
virtual void PTL::PackagedTask< RetT, Args >::wait ( )
inlinefinalvirtual

Implements PTL::TaskFuture< RetT >.

Definition at line 119 of file Task.hh.

119{ return m_ptask.get_future().wait(); }

References PTL::PackagedTask< RetT, Args >::m_ptask.

Field Documentation

◆ m_args

template<typename RetT , typename... Args>
tuple_type PTL::PackagedTask< RetT, Args >::m_args
private

Definition at line 124 of file Task.hh.

Referenced by PTL::PackagedTask< RetT, Args >::operator()().

◆ m_depth

intmax_t PTL::VTask::m_depth = 0
protectedinherited

Definition at line 82 of file VTask.hh.

Referenced by PTL::VTask::depth().

◆ m_func

void_func_t PTL::VTask::m_func = []() {}
protectedinherited

Definition at line 83 of file VTask.hh.

◆ m_is_native

bool PTL::VTask::m_is_native = false
protectedinherited

Definition at line 81 of file VTask.hh.

Referenced by PTL::VTask::is_native_task().

◆ m_ptask

template<typename RetT , typename... Args>
packaged_task_type PTL::PackagedTask< RetT, Args >::m_ptask
private

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