Skip to content

Commit

Permalink
next_functions_task removed
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanPinezhaninov committed Dec 3, 2023
1 parent 7ed4b35 commit 9cc1630
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions include/async_promise.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,28 +793,14 @@ class all_settled_task_void<Result, ParentResult, void, Container, Func, Allocat

template<typename Result, typename ParentResult,
template<typename, typename> class Container, typename Func, typename Allocator>
class next_functions_task : public next_task<Result, ParentResult>, public promise_helper<Result>
class any_task_base : public next_task<Result, ParentResult>, public promise_helper<Result>
{
public:
next_functions_task(task_ptr<ParentResult> parent, Container<Func, Allocator> funcs)
any_task_base(task_ptr<ParentResult> parent, Container<Func, Allocator> funcs)
: next_task<Result, ParentResult>{std::move(parent)}
, m_funcs{std::move(funcs)}
{}

protected:
Container<Func, Allocator> m_funcs;
};


template<typename Result, typename ParentResult,
template<typename, typename> class Container, typename Func, typename Allocator>
class any_task_base : public next_functions_task<Result, ParentResult, Container, Func, Allocator>
{
public:
any_task_base(task_ptr<ParentResult> parent, Container<Func, Allocator> funcs)
: next_functions_task<Result, ParentResult, Container, Func, Allocator>{std::move(parent), std::move(funcs)}
{}

Result run() final
{
auto future = this->m_promise.get_future();
Expand Down Expand Up @@ -842,10 +828,12 @@ class any_task_base : public next_functions_task<Result, ParentResult, Container
if (m_errors.size() < this->m_funcs.size())
return;

next_functions_task<Result, ParentResult, Container, Func, Allocator>
::reject(std::make_exception_ptr(aggregate_error{std::move(m_errors)}));
promise_helper<Result>::reject(std::make_exception_ptr(aggregate_error{std::move(m_errors)}));
}

protected:
Container<Func, Allocator> m_funcs;

private:
virtual void async_run(std::vector<std::future<void>>& futures) = 0;

Expand Down Expand Up @@ -986,11 +974,12 @@ class any_task_void<void, ParentResult, Container, Func, Allocator> final

template<typename Result, typename ParentResult,
template<typename, typename> class Container, typename Func, typename Allocator>
class race_task_base : public next_functions_task<Result, ParentResult, Container, Func, Allocator>
class race_task_base : public next_task<Result, ParentResult>, public promise_helper<Result>
{
public:
race_task_base(task_ptr<ParentResult> parent, Container<Func, Allocator> funcs)
: next_functions_task<Result, ParentResult, Container, Func, Allocator>{std::move(parent), std::move(funcs)}
: next_task<Result, ParentResult>{std::move(parent)}
, m_funcs{std::move(funcs)}
{}

Result run() final
Expand All @@ -1010,6 +999,9 @@ class race_task_base : public next_functions_task<Result, ParentResult, Containe
}
}

protected:
Container<Func, Allocator> m_funcs;

private:
virtual void async_run(std::vector<std::future<void>>& futures) = 0;
};
Expand Down

0 comments on commit 9cc1630

Please sign in to comment.