Geant4 11.2.2
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

using this_type = Task<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 >
 Task (FuncT func, Args... args)
 
template<typename FuncT >
 Task (bool _is_native, intmax_t _depth, FuncT func, Args... args)
 
 ~Task () override=default
 
 Task (const Task &)=delete
 
Taskoperator= (const Task &)=delete
 
 Task (Task &&) noexcept=default
 
Taskoperator= (Task &&) 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
 
- 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
 
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::Task< RetT, Args >

The task class is supplied to thread_pool.

Definition at line 130 of file Task.hh.

Member Typedef Documentation

◆ future_type

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

Definition at line 135 of file Task.hh.

◆ packaged_task_type

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

Definition at line 136 of file Task.hh.

◆ promise_type

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

Definition at line 134 of file Task.hh.

◆ result_type

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

Definition at line 137 of file Task.hh.

◆ this_type

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

Definition at line 133 of file Task.hh.

◆ tuple_type

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

Definition at line 138 of file Task.hh.

Constructor & Destructor Documentation

◆ Task() [1/4]

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

Definition at line 142 of file Task.hh.

144 , m_ptask{ std::move(func) }
145 , m_args{ args... }
146 {}
TaskFuture(Args &&... args)
Definition Task.hh:57

◆ Task() [2/4]

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

Definition at line 149 of file Task.hh.

150 : TaskFuture<RetT>{ _is_native, _depth }
151 , m_ptask{ std::move(func) }
152 , m_args{ args... }
153 {}

◆ ~Task()

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

◆ Task() [3/4]

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

◆ Task() [4/4]

template<typename RetT , typename... Args>
PTL::Task< RetT, Args >::Task ( Task< RetT, Args > && )
defaultnoexcept

Member Function Documentation

◆ get()

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

Implements PTL::TaskFuture< RetT >.

Definition at line 172 of file Task.hh.

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

◆ get_future()

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

Implements PTL::TaskFuture< RetT >.

Definition at line 170 of file Task.hh.

170{ return m_ptask.get_future(); }

◆ operator()()

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

Implements PTL::VTask.

Definition at line 165 of file Task.hh.

166 {
167 if(m_ptask.valid())
168 mpl::apply(std::move(m_ptask), std::move(m_args));
169 }

◆ operator=() [1/2]

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

◆ operator=() [2/2]

template<typename RetT , typename... Args>
Task & PTL::Task< RetT, Args >::operator= ( Task< RetT, Args > && )
defaultnoexcept

◆ wait()

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

Implements PTL::TaskFuture< RetT >.

Definition at line 171 of file Task.hh.

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

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