C/C++ API Reference
Loading...
Searching...
No Matches
pw::async2::CoroTask< T, ReturnValuePolicy::kDiscard > Class Template Referencefinal

Overview

template<typename T>
class pw::async2::CoroTask< T, ReturnValuePolicy::kDiscard >

CoroTask specialization that discards the coroutine's return value.

Inheritance diagram for pw::async2::CoroTask< T, ReturnValuePolicy::kDiscard >:
pw::async2::Task pw::IntrusiveQueue< T >::Item pw::async2::Context

Public Member Functions

 CoroTask (Coro< T > &&coro)
 
 CoroTask (const CoroTask &)=delete
 
CoroTaskoperator= (const CoroTask &)=delete
 
 CoroTask (CoroTask &&)=delete
 
CoroTaskoperator= (CoroTask &&)=delete
 
bool ok () const
 
- Public Member Functions inherited from pw::async2::Task
constexpr Task (log::Token name=kDefaultName)
 
 Task (const Task &)=delete
 
 Task (Task &&)=delete
 
Taskoperator= (const Task &)=delete
 
Taskoperator= (Task &&)=delete
 
virtual ~Task ()
 
Poll Pend (Context &cx)
 
bool IsRegistered () const
 
void Deregister ()
 
void Join ()
 

Private Member Functions

Poll DoPend (Context &cx) final
 

Additional Inherited Members

- Protected Types inherited from pw::async2::Task
using Context = ::pw::async2::Context
 

Constructor & Destructor Documentation

◆ CoroTask()

template<typename T >
pw::async2::CoroTask< T, ReturnValuePolicy::kDiscard >::CoroTask ( Coro< T > &&  coro)
inline

Creates a task that runs the provided coroutine.

If the Coro is empty or failed to allocate, this CoroTask crashes when Pend is called.

Member Function Documentation

◆ DoPend()

template<typename T >
Poll pw::async2::CoroTask< T, ReturnValuePolicy::kDiscard >::DoPend ( Context )
inlinefinalprivatevirtual

Attempts to advance this Task to completion.

This method should not perform synchronous waiting, as doing so may block the main Dispatcher loop and prevent other Task s from progressing. Because of this, Task s should not invoke blocking Dispatcher methods such as RunUntilComplete.

Tasks should also avoid invoking RunUntilStalled on their own Dispatcher.

Returns Ready if complete, or Pending if the Task was not yet able to complete.

If Pending is returned, the Task must ensure it is woken up when it is able to make progress. To do this, Task::Pend must arrange for Waker::Wake to be called, either by storing a copy of the Waker away to be awoken by another system (such as an interrupt handler).

Implements pw::async2::Task.

◆ ok()

template<typename T >
bool pw::async2::CoroTask< T, ReturnValuePolicy::kDiscard >::ok ( ) const
inline

Returns whether this CoroTask wraps a valid Coro and can be pended. Pending a !ok() CoroTask will crash.

This will be false if Coro allocation failed.


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