Pigweed
C/C++ API Reference
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
pw::async2::Context Class Reference

Public Member Functions

 Context (Dispatcher &dispatcher, Waker &waker)
 
Dispatcherdispatcher ()
 
void ReEnqueue ()
 
template<typename T = ReadyType>
Poll< T > Unschedule ()
 

Friends

class NativeDispatcherBase
 
bool internal::StoreWaker (Context &cx, Waker &waker_out, log::Token wait_reason)
 
bool internal::StoreWaker (Context &cx, internal::WakerQueueBase &queue, log::Token wait_reason)
 

Detailed Description

Context for an asynchronous Task.

This object contains resources needed for scheduling asynchronous work, such as the current Dispatcher and the Waker for the current task.

Context s are most often created by Dispatcher s, which pass them into Task::Pend.

Constructor & Destructor Documentation

◆ Context()

pw::async2::Context::Context ( Dispatcher dispatcher,
Waker waker 
)
inline

Creates a new Context containing the currently-running Dispatcher and a Waker for the current Task.

Member Function Documentation

◆ dispatcher()

Dispatcher & pw::async2::Context::dispatcher ( )
inline

The Dispatcher on which the current Task is executing.

This can be used for spawning new tasks using dispatcher().Post(task);.

◆ ReEnqueue()

void pw::async2::Context::ReEnqueue ( )

Queues the current Task::Pend to run again in the future, possibly after other work is performed.

This may be used by Task implementations that wish to provide additional fairness by yielding to the dispatch loop rather than perform too much work in a single iteration.

This is semantically equivalent to calling:

Waker waker;
PW_ASYNC_STORE_WAKER(cx, waker, ...);
std::move(waker).Wake();
Definition: waker.h:148

◆ Unschedule()

template<typename T = ReadyType>
Poll< T > pw::async2::Context::Unschedule ( )
inline

Indicates that the task has not completed, but that it also does not need to register a waker and go to sleep. This results in the task being


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