C/C++ API Reference
Loading...
Searching...
No Matches
pw_async2

Overview

Cooperative async tasks for embedded.

Main docs: Home | Quickstart | Codelab | Guides | Code size analysis | Coroutines | Dispatcher |

Submodules

 Built-in pendables
 Async operations that can be polled for completion and suspended. Learn more: The pendable function interface
 
 Combinators
 Helpers for interacting with multiple pendables.
 
 Core
 Core primitives such as tasks, polls, contexts, and wakers.
 
 Coroutines
 C++20 coroutine support. Learn more: Coroutines
 
 Dispatcher
 Dispatcher interface and implementations.
 
 Dynamic allocation
 Heap allocate space for tasks or functions with pw::Allocator
 
 Pendable adapters
 Pendable wrappers and helpers.
 

Classes

class  pw::async2::internal::PendableAsTaskWithOutput< Pendable >
 
class  pw::async2::DispatcherForTestFacade< Native >
 

Typedefs

using pw::async2::internal::PendableAsTaskWithOutput< Pendable >::value_type = PendOutputOf< Pendable >
 
using pw::async2::DispatcherForTest = DispatcherForTestFacade< backend::NativeDispatcherForTest >
 

Functions

 pw::async2::internal::PendableAsTaskWithOutput< Pendable >::PendableAsTaskWithOutput (Pendable &pendable)
 
Poll< value_type > pw::async2::internal::PendableAsTaskWithOutput< Pendable >::TakePoll ()
 
Poll pw::async2::internal::PendableAsTaskWithOutput< Pendable >::DoPend (Context &cx) final
 
 pw::async2::DispatcherForTestFacade< Native >::DispatcherForTestFacade ()=default
 DispatcherForTest is default constructible.
 
 pw::async2::DispatcherForTestFacade< Native >::DispatcherForTestFacade (const DispatcherForTestFacade &)=delete
 
DispatcherForTestFacadepw::async2::DispatcherForTestFacade< Native >::operator= (const DispatcherForTestFacade &)=delete
 
 pw::async2::DispatcherForTestFacade< Native >::DispatcherForTestFacade (DispatcherForTestFacade &&)=delete
 
DispatcherForTestFacadepw::async2::DispatcherForTestFacade< Native >::operator= (DispatcherForTestFacade &&)=delete
 
void pw::async2::DispatcherForTestFacade< Native >::AllowBlocking ()
 
template<typename Pendable >
Poll< internal::PendOutputOf< Pendable > > pw::async2::DispatcherForTestFacade< Native >::RunInTaskUntilStalled (Pendable &pendable)
 
uint32_t pw::async2::DispatcherForTestFacade< Native >::tasks_polled () const
 
uint32_t pw::async2::DispatcherForTestFacade< Native >::tasks_completed () const
 Returns the total number of tasks the dispatcher has run to completion.
 
uint32_t pw::async2::DispatcherForTestFacade< Native >::wake_count () const
 Returns the total number of times the dispatcher has been woken.
 
void pw::async2::DispatcherForTestFacade< Native >::DoWake () override
 
void pw::async2::DispatcherForTestFacade< Native >::DoWaitForWake () override
 

Typedef Documentation

◆ DispatcherForTest

using pw::async2::DispatcherForTest = typedef DispatcherForTestFacade<backend::NativeDispatcherForTest>

DispatcherForTest is a RunnableDispatcher implementation to use in unit tests. See DispatcherForTestFacade for details.

Function Documentation

◆ AllowBlocking()

template<typename Native >
void pw::async2::DispatcherForTestFacade< Native >::AllowBlocking ( )
inline

Whether to allow the dispatcher to block by calling DoWaitForWake. RunToCompletion may block the thread if there are no tasks ready to run.

◆ DoPend()

template<typename Pendable >
Poll pw::async2::internal::PendableAsTaskWithOutput< Pendable >::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.

◆ DoRunUntilStalled()

template<typename Native >
bool pw::async2::DispatcherForTestFacade< Native >::DoRunUntilStalled ( )
overrideprivatevirtual

Reimplemented from pw::async2::RunnableDispatcher.

◆ DoWaitForWake()

template<typename Native >
void pw::async2::DispatcherForTestFacade< Native >::DoWaitForWake ( )
overrideprivatevirtual

Blocks until DoWake() is called. Must return immediately if DoWake() was already called since the last DoWaitForWake call.

If the implementation is unable to block the thread, it must crash.

Implements pw::async2::RunnableDispatcher.

◆ DoWake()

template<typename Native >
void pw::async2::DispatcherForTestFacade< Native >::DoWake ( )
overrideprivatevirtual

Sends a wakeup signal to this Dispatcher.

This method's implementation must ensure that the Dispatcher runs at some point in the future.

DoWake() will only be called once until one of the following occurs:

Note
The internal::lock() may or may not be held here, so it must not be acquired by DoWake, nor may DoWake assume that it has been acquired.

Implements pw::async2::Dispatcher.

◆ tasks_polled()

template<typename Native >
uint32_t pw::async2::DispatcherForTestFacade< Native >::tasks_polled ( ) const
inline

Returns the total number of times the dispatcher has called a task's Pend() method.