Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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 >:

Public Types

using this_type = PackagedTask< RetT, Args... >
 
using promise_type = std::promise< RetT >
 
using future_type = std::future< RetT >
 
using packaged_task_type = std::packaged_task< RetT(Args...)>
 
using result_type = RetT
 
using tuple_type = std::tuple< Args... >
 
- Public Types inherited from PTL::TaskFuture< RetT >
using promise_type = std::promise< RetT >
 
using future_type = std::future< RetT >
 
using result_type = RetT
 
- Public Types inherited from PTL::VTask
using tid_type = std::thread::id
 
using size_type = size_t
 
using void_func_t = std::function< void()>
 

Public Member Functions

template<typename FuncT >
 PackagedTask (FuncT func, Args... args)
 
template<typename FuncT >
 PackagedTask (bool _is_native, intmax_t _depth, FuncT func, Args... args)
 
 ~PackagedTask () override=default
 
 PackagedTask (const PackagedTask &)=delete
 
PackagedTaskoperator= (const PackagedTask &)=delete
 
 PackagedTask (PackagedTask &&) noexcept=default
 
PackagedTaskoperator= (PackagedTask &&) noexcept=default
 
void operator() () final
 
future_type get_future () final
 
void wait () final
 
RetT get () final
 
- Public Member Functions inherited from PTL::TaskFuture< RetT >
template<typename... Args>
 TaskFuture (Args &&... args)
 
 ~TaskFuture () override=default
 
 TaskFuture (const TaskFuture &)=delete
 
TaskFutureoperator= (const TaskFuture &)=delete
 
 TaskFuture (TaskFuture &&) noexcept=default
 
TaskFutureoperator= (TaskFuture &&) noexcept=default
 
virtual future_type get_future ()=0
 
virtual void wait ()=0
 
virtual RetT get ()=0
 
- Public Member Functions inherited from PTL::VTask
 VTask (bool _is_native, intmax_t _depth)
 
 VTask ()=default
 
virtual ~VTask ()=default
 
 VTask (const VTask &)=delete
 
VTaskoperator= (const VTask &)=delete
 
 VTask (VTask &&)=default
 
VTaskoperator= (VTask &&)=default
 
virtual void operator() ()=0
 
bool is_native_task () const
 
intmax_t depth () const
 

Additional Inherited Members

- Protected Attributes inherited from PTL::VTask
bool m_is_native = false
 
intmax_t m_depth = 0
 
void_func_t m_func = []() {}
 

Detailed Description

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

The task class is supplied to thread_pool.

Definition at line 80 of file Task.hh.

Member Typedef Documentation

◆ future_type

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

Definition at line 85 of file Task.hh.

◆ packaged_task_type

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

Definition at line 86 of file Task.hh.

◆ promise_type

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

Definition at line 84 of file Task.hh.

◆ result_type

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

Definition at line 87 of file Task.hh.

◆ this_type

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

Definition at line 83 of file Task.hh.

◆ tuple_type

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

Definition at line 88 of file Task.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 93 of file Task.hh.

94 : TaskFuture<RetT>{ true, 0 }
95 , m_ptask{ std::move(func) }
96 , m_args{ args... }
97 {}

◆ 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 100 of file Task.hh.

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

◆ ~PackagedTask()

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

◆ 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 > &&  )
defaultnoexcept

Member Function Documentation

◆ get()

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

Implements PTL::TaskFuture< RetT >.

Definition at line 119 of file Task.hh.

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

◆ get_future()

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

Implements PTL::TaskFuture< RetT >.

Definition at line 117 of file Task.hh.

117{ return m_ptask.get_future(); }

◆ operator()()

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

Implements PTL::VTask.

Definition at line 116 of file Task.hh.

116{ mpl::apply(std::move(m_ptask), std::move(m_args)); }

◆ 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 > &&  )
defaultnoexcept

◆ wait()

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

Implements PTL::TaskFuture< RetT >.

Definition at line 118 of file Task.hh.

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

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