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

using this_type = Task< RetT >
 
using promise_type = std::promise< RetT >
 
using future_type = std::future< RetT >
 
using packaged_task_type = std::packaged_task< RetT()>
 
using result_type = RetT
 
- 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)
 
template<typename FuncT >
 Task (bool _is_native, intmax_t _depth, FuncT func)
 
virtual ~Task ()=default
 
 Task (const Task &)=delete
 
Taskoperator= (const Task &)=delete
 
 Task (Task &&) noexcept=default
 
Taskoperator= (Task &&) noexcept=default
 
virtual void operator() () final
 
virtual future_type get_future () final
 
virtual void wait () final
 
virtual 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>
class PTL::Task< RetT, void >

The task class is supplied to thread_pool.

Definition at line 183 of file Task.hh.

Member Typedef Documentation

◆ future_type

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

Definition at line 188 of file Task.hh.

◆ packaged_task_type

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

Definition at line 189 of file Task.hh.

◆ promise_type

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

Definition at line 187 of file Task.hh.

◆ result_type

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

Definition at line 190 of file Task.hh.

◆ this_type

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

Definition at line 186 of file Task.hh.

Constructor & Destructor Documentation

◆ Task() [1/4]

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

Definition at line 194 of file Task.hh.

195 : TaskFuture<RetT>()
196 , m_ptask{ std::move(func) }
197 {}

◆ Task() [2/4]

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

Definition at line 200 of file Task.hh.

201 : TaskFuture<RetT>{ _is_native, _depth }
202 , m_ptask{ std::move(func) }
203 {}

◆ ~Task()

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

◆ Task() [3/4]

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

◆ Task() [4/4]

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

Member Function Documentation

◆ get()

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

Implements PTL::TaskFuture< RetT >.

Definition at line 218 of file Task.hh.

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

◆ get_future()

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

Implements PTL::TaskFuture< RetT >.

Definition at line 216 of file Task.hh.

216{ return m_ptask.get_future(); }

◆ operator()()

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

Implements PTL::VTask.

Definition at line 215 of file Task.hh.

215{ m_ptask(); }

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ wait()

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

Implements PTL::TaskFuture< RetT >.

Definition at line 217 of file Task.hh.

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

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