46template <
typename RetT>
56 template <
typename... Args>
58 :
VTask{
std::forward<Args>(args)... }
73 virtual RetT
get() = 0;
79template <typename RetT, typename... Args>
92 template <
typename FuncT>
95 , m_ptask{ std::move(func) }
99 template <
typename FuncT>
100 PackagedTask(
bool _is_native, intmax_t _depth, FuncT func, Args... args)
102 , m_ptask{ std::move(func) }
116 void operator()() final { PTL::apply(std::move(m_ptask), std::move(m_args)); }
118 void wait() final {
return m_ptask.get_future().wait(); }
119 RetT
get() final {
return m_ptask.get_future().get(); }
122 packaged_task_type m_ptask;
129template <
typename RetT,
typename... Args>
141 template <
typename FuncT>
144 , m_ptask{ std::move(func) }
148 template <
typename FuncT>
149 Task(
bool _is_native, intmax_t _depth, FuncT func, Args... args)
151 , m_ptask{ std::move(func) }
165 void operator()() final
168 PTL::apply(std::move(m_ptask), std::move(m_args));
171 void wait() final {
return m_ptask.get_future().wait(); }
172 RetT
get() final {
return m_ptask.get_future().get(); }
175 packaged_task_type m_ptask{};
182template <
typename RetT>
193 template <
typename FuncT>
196 , m_ptask{
std::move(func) }
199 template <
typename FuncT>
200 Task(
bool _is_native, intmax_t _depth, FuncT func)
202 , m_ptask{ std::move(func) }
215 virtual
void operator()() final { m_ptask(); }
217 virtual void wait() final {
return m_ptask.get_future().wait(); }
218 virtual RetT
get() final {
return m_ptask.get_future().get(); }
221 packaged_task_type m_ptask{};
228class Task<void, void> :
public TaskFuture<void>
232 using this_type = Task<void, void>;
233 using promise_type = std::promise<RetT>;
234 using future_type = std::future<RetT>;
235 using packaged_task_type = std::packaged_task<RetT()>;
236 using result_type = RetT;
239 template <
typename FuncT>
240 explicit Task(FuncT func)
242 , m_ptask{ std::move(func) }
245 template <
typename FuncT>
246 Task(
bool _is_native, intmax_t _depth, FuncT func)
247 : TaskFuture<RetT>{ _is_native, _depth }
248 , m_ptask{ std::move(func) }
251 ~Task()
override =
default;
253 Task(
const Task&) =
delete;
254 Task& operator=(
const Task&) =
delete;
256 Task(Task&&) =
default;
257 Task& operator=(Task&&) =
default;
261 void operator()() final { m_ptask(); }
262 future_type get_future() final {
return m_ptask.get_future(); }
263 void wait() final {
return m_ptask.get_future().wait(); }
264 RetT get() final {
return m_ptask.get_future().get(); }
267 packaged_task_type m_ptask{};
PackagedTask(const PackagedTask &)=delete
std::future< RetT > future_type
std::tuple< Args... > tuple_type
PackagedTask(bool _is_native, intmax_t _depth, FuncT func, Args... args)
future_type get_future() final
PackagedTask(FuncT func, Args... args)
PackagedTask & operator=(const PackagedTask &)=delete
std::packaged_task< RetT(Args...)> packaged_task_type
PackagedTask(PackagedTask &&) noexcept=default
PackagedTask< RetT, Args... > this_type
std::promise< RetT > promise_type
~PackagedTask() override=default
std::promise< RetT > promise_type
TaskFuture(const TaskFuture &)=delete
TaskFuture & operator=(const TaskFuture &)=delete
std::future< RetT > future_type
~TaskFuture() override=default
TaskFuture(Args &&... args)
TaskFuture(TaskFuture &&) noexcept=default
virtual future_type get_future()=0
std::future< RetT > future_type
Task & operator=(const Task &)=delete
Task(bool _is_native, intmax_t _depth, FuncT func)
Task(const Task &)=delete
std::promise< RetT > promise_type
std::packaged_task< RetT()> packaged_task_type
virtual future_type get_future() final
Task(Task &&) noexcept=default
virtual void wait() final
Task< RetT, Args... > this_type
std::future< RetT > future_type
Task & operator=(const Task &)=delete
Task(FuncT func, Args... args)
future_type get_future() final
std::promise< RetT > promise_type
std::tuple< Args... > tuple_type
Task(bool _is_native, intmax_t _depth, FuncT func, Args... args)
Task(const Task &)=delete
std::packaged_task< RetT(Args...)> packaged_task_type
Task(Task &&) noexcept=default
VTask(bool _is_native, intmax_t _depth)
Backports of C++ language features for use with C++11 compilers.