Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanPinezhaninov committed Dec 2, 2023
1 parent 9741aee commit 2666d89
Showing 1 changed file with 47 additions and 47 deletions.
94 changes: 47 additions & 47 deletions include/async_promise.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,53 +295,6 @@ class promise_helper
};


template<typename Result>
class resolve_task final : public task<Result>
{
public:
template<typename T>
explicit resolve_task(T&& val)
: m_val{std::forward<T>(val)}
{}

Result run() final
{
return m_val;
}

private:
Result m_val;
};


template<>
class resolve_task<void> final : public task<void>
{
public:
void run() final
{}
};


template<typename Result, typename Error>
class reject_task final : public task<Result>
{
public:
template<typename T>
explicit reject_task(T&& error)
: m_error{std::forward<T>(error)}
{}

Result run() final
{
std::rethrow_exception(std::make_exception_ptr(std::move(m_error)));
}

private:
Error m_error;
};


template<typename Result, typename Func, typename... Args>
class initial_task final : public task<Result>
{
Expand Down Expand Up @@ -1568,6 +1521,53 @@ class race_task_static<void, Container, Func, Allocator, Args...> final
std::tuple<Args...> m_args;
};


template<typename Result>
class resolve_task final : public task<Result>
{
public:
template<typename T>
explicit resolve_task(T&& val)
: m_val{std::forward<T>(val)}
{}

Result run() final
{
return m_val;
}

private:
Result m_val;
};


template<>
class resolve_task<void> final : public task<void>
{
public:
void run() final
{}
};


template<typename Result, typename Error>
class reject_task final : public task<Result>
{
public:
template<typename T>
explicit reject_task(T&& error)
: m_error{std::forward<T>(error)}
{}

Result run() final
{
std::rethrow_exception(std::make_exception_ptr(std::move(m_error)));
}

private:
Error m_error;
};

} // namespace internal


Expand Down

0 comments on commit 2666d89

Please sign in to comment.