dpp::task
dpp::awaitable< R >
coro/task.h
typename R
detail::task::handle_t< R > using dpp::task< R >::handle_t = detail::task::handle_t<R> handle_t dpp::task::handle_t
detail::promise::state_flags using dpp::task< R >::state_flags = detail::promise::state_flags state_flags dpp::task::state_flags
struct friend struct detail::task::promise_t< R > detail::task::promise_t< R > dpp::task::promise_t< R > detail::task::promise_t< R >
handle_t handle_t dpp::task< R >::handle handle dpp::task::handle {}
dpp::task< R >::task
(handle_t handle_)
task
dpp::task::task
handle_t handle_

Construct from a coroutine handle. Internal use only.

uint8_t auto dpp::awaitable< R >::abandon () abandon dpp::awaitable< R >::abandon

Abandons the promise.

Set the promise's state to broken and unlinks this awaitable.

uint8_t Flags previously held before setting them to broken

void void dpp::task< R >::cleanup () cleanup dpp::task::cleanup

Clean up our handle, cancelling any running task.

auto auto dpp::basic_awaitable< Derived >::sync_wait_impl (auto &&do_wait) sync_wait_impl dpp::awaitable< R >::sync_wait_impl auto && do_wait

Implementation for sync_wait. This is code used by sync_wait, sync_wait_for, sync_wait_until.

Timed

Whether the wait function times out or not

do_wait

Function to do the actual wait on the cv

If T is void, returns a boolean for which true means the awaitable completed, false means it timed out.

If T is non-void, returns a std::optional<T> for which an absence of value means timed out.

auto auto dpp::basic_awaitable< Derived >::sync_wait_impl (auto &&do_wait) sync_wait_impl dpp::basic_awaitable< awaitable< R > >::sync_wait_impl auto && do_wait

Implementation for sync_wait. This is code used by sync_wait, sync_wait_for, sync_wait_until.

Timed

Whether the wait function times out or not

do_wait

Function to do the actual wait on the cv

If T is void, returns a boolean for which true means the awaitable completed, false means it timed out.

If T is non-void, returns a std::optional<T> for which an absence of value means timed out.

dpp::task< R >::task
()=default
task
dpp::task::task

Default constructor, creates a task not bound to a coroutine.

dpp::task< R >::task
(const task &)=delete
task
dpp::task::task
const task &

Copy constructor is disabled.

dpp::task< R >::task
(task &&other) noexcept
task
dpp::task::task
task && other

Move constructor, grabs another task's coroutine handle.

other

Task to move the handle from

dpp::task< R >::~task
()
~task
dpp::task::~task

Destructor.

Destroys the handle. If the task is still running, it will be cancelled.

bool bool dpp::awaitable< R >::await_ready () const await_ready dpp::awaitable< R >::await_ready

Check whether or not co_await-ing this would suspend the caller, i.e. if we have the result or not.

bool Whether we already have the result or not

task && task && dpp::task< R >::cancel () &&noexcept cancel dpp::task::cancel

Cancel the task, it will stop the next time it uses co_await. On co_await-ing this task, throws dpp::task_cancelled_exception.

*this

task & task & dpp::task< R >::cancel () &noexcept cancel dpp::task::cancel

Cancel the task, it will stop the next time it uses co_await. On co_await-ing this task, throws dpp::task_cancelled_exception.

*this

bool bool dpp::task< R >::done () const noexcept done dpp::task::done

Function to check if the task has finished its execution entirely.

bool Whether the task is finished.

void void dpp::awaitable< R >::if_this_causes_an_invalid_read_your_promise_was_destroyed_before_your_awaitable____check_your_promise_lifetime () if_this_causes_an_invalid_read_your_promise_was_destroyed_before_your_awaitable____check_your_promise_lifetime dpp::awaitable< R >::if_this_causes_an_invalid_read_your_promise_was_destroyed_before_your_awaitable____check_your_promise_lifetime

Title :).

We use this in the destructor

task & task & dpp::task< R >::operator= (const task &)=delete operator= dpp::task::operator= const task &

Copy assignment is disabled.

task & task & dpp::task< R >::operator= (task &&other) noexcept operator= dpp::task::operator= task && other

Move assignment, grabs another task's coroutine handle.

other

Task to move the handle from

auto auto dpp::basic_awaitable< Derived >::sync_wait () sync_wait dpp::awaitable< R >::sync_wait

Blocks this thread and waits for the awaitable to finish.

This will BLOCK THE THREAD. It is likely you want to use co_await instead.

If T is void, returns a boolean for which true means the awaitable completed, false means it timed out.

If T is non-void, returns a std::optional<T> for which an absence of value means timed out.

auto auto dpp::basic_awaitable< Derived >::sync_wait () sync_wait dpp::basic_awaitable< awaitable< R > >::sync_wait

Blocks this thread and waits for the awaitable to finish.

This will BLOCK THE THREAD. It is likely you want to use co_await instead.

If T is void, returns a boolean for which true means the awaitable completed, false means it timed out.

If T is non-void, returns a std::optional<T> for which an absence of value means timed out.

auto auto dpp::basic_awaitable< Derived >::sync_wait_for (const std::chrono::duration< Rep, Period > &duration) sync_wait_for dpp::awaitable< R >::sync_wait_for const std::chrono::duration< Rep, Period > & duration

Blocks this thread and waits for the awaitable to finish.

This will BLOCK THE THREAD. It is likely you want to use co_await instead.

duration

Maximum duration to wait for

If T is void, returns a boolean for which true means the awaitable completed, false means it timed out.

If T is non-void, returns a std::optional<T> for which an absence of value means timed out.

auto auto dpp::basic_awaitable< Derived >::sync_wait_for (const std::chrono::duration< Rep, Period > &duration) sync_wait_for dpp::basic_awaitable< awaitable< R > >::sync_wait_for const std::chrono::duration< Rep, Period > & duration

Blocks this thread and waits for the awaitable to finish.

This will BLOCK THE THREAD. It is likely you want to use co_await instead.

duration

Maximum duration to wait for

If T is void, returns a boolean for which true means the awaitable completed, false means it timed out.

If T is non-void, returns a std::optional<T> for which an absence of value means timed out.

auto auto dpp::basic_awaitable< Derived >::sync_wait_until (const std::chrono::time_point< Clock, Duration > &time) sync_wait_until dpp::awaitable< R >::sync_wait_until const std::chrono::time_point< Clock, Duration > & time

Blocks this thread and waits for the awaitable to finish.

This will BLOCK THE THREAD. It is likely you want to use co_await instead.

time

Maximum time point to wait for

If T is void, returns a boolean for which true means the awaitable completed, false means it timed out.

If T is non-void, returns a std::optional<T> for which an absence of value means timed out.

auto auto dpp::basic_awaitable< Derived >::sync_wait_until (const std::chrono::time_point< Clock, Duration > &time) sync_wait_until dpp::basic_awaitable< awaitable< R > >::sync_wait_until const std::chrono::time_point< Clock, Duration > & time

Blocks this thread and waits for the awaitable to finish.

This will BLOCK THE THREAD. It is likely you want to use co_await instead.

time

Maximum time point to wait for

If T is void, returns a boolean for which true means the awaitable completed, false means it timed out.

If T is non-void, returns a std::optional<T> for which an absence of value means timed out.

bool bool dpp::awaitable< R >::valid () const noexcept valid dpp::awaitable< R >::valid

Check whether this awaitable refers to a valid promise.

bool Whether this awaitable refers to a valid promise or not

R using dpp::awaitable< R >::result_type = result_type dpp::awaitable< R >::result_type

The type of the result produced by this task.

detail::promise::promise_base< R > using dpp::awaitable< R >::shared_state = shared_state dpp::awaitable< R >::shared_state
shared_state * shared_state* dpp::awaitable< R >::state_ptr state_ptr dpp::awaitable< R >::state_ptr

Non-owning pointer to the promise, which must be kept alive for the entire lifetime of the awaitable.

A coroutine task. It starts immediately on construction and can be co_await-ed, making it perfect for parallel coroutines returning a value.

- This feature is EXPERIMENTAL. The API may change at any time and there may be bugs. Please report any to GitHub Issues or to our Discord Server.

R

Return type of the task. Cannot be a reference but can be void.

dpp::awaitable< T >
dpp::awaitable< R >
< R >
dpp::basic_awaitable< Derived >
dpp::basic_awaitable< awaitable< R > >
< awaitable< R > >
dpp::basic_awaitable< awaitable< T > >
< awaitable< T > >
dpp::task< R >
T
dpp::awaitable< T >
state_ptr
dpp::awaitable< R >
state_ptr
< R >
dpp::basic_awaitable< Derived >
dpp::basic_awaitable< awaitable< R > >
< awaitable< R > >
dpp::basic_awaitable< awaitable< T > >
< awaitable< T > >
dpp::detail::promise::promise_base< T >
value
state
awaiter
dpp::task< R >
result_t< T >
std::atomic< T >
ptr
std::atomic< uint8_t >
ptr
< uint8_t >
coroutine_handle
uint8_t
- dpp::task
  abandon
- dpp::task
  await_ready
- dpp::task
  awaitable
- dpp::task
  cancel
- dpp::task
  cancel
- dpp::task
  cleanup
- dpp::task
  detail::task::promise_t< R >
- dpp::task
  done
- dpp::task
  handle
- dpp::task
  handle_t
- dpp::task
  if_this_causes_an_invalid_read_your_promise_was_destroyed_before_your_awaitable____check_your_promise_lifetime
- dpp::task
  operator=
- dpp::task
  operator=
- dpp::task
  operator=
- dpp::task
  result_type
- dpp::task
  shared_state
- dpp::task
  state_flags
- dpp::task
  state_ptr
- dpp::task
  sync_wait
- dpp::task
  sync_wait
- dpp::task
  sync_wait_for
- dpp::task
  sync_wait_for
- dpp::task
  sync_wait_impl
- dpp::task
  sync_wait_impl
- dpp::task
  sync_wait_until
- dpp::task
  sync_wait_until
- dpp::task
  task
- dpp::task
  task
- dpp::task
  task
- dpp::task
  task
- dpp::task
  valid
- dpp::task
  ~awaitable
- dpp::task
  ~task