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::Waker Class Reference
Inheritance diagram for pw::async2::Waker:
pw::IntrusiveForwardList< T >::Item

Public Member Functions

 Waker (Waker &&other) noexcept
 
Wakeroperator= (Waker &&other) noexcept
 
void Wake () &&
 
bool IsEmpty () const
 
void Clear ()
 

Friends

class Task
 
class NativeDispatcherBase
 
class internal::WakerQueueBase
 
bool internal::CloneWaker (Waker &waker_in, Waker &waker_out, log::Token wait_reason)
 

Additional Inherited Members

- Protected Member Functions inherited from pw::IntrusiveForwardList< T >::Item
constexpr Item ()=default
 

Detailed Description

An object which can respond to asynchronous events by queueing work to be done in response, such as placing a Task on a Dispatcher loop.

Waker s are often held by I/O objects, custom concurrency primitives, or interrupt handlers. Once the thing the Task was waiting for is available, Wake should be called so that the Task is alerted and may process the event.

Waker s may be held for any lifetime, and will be automatically nullified when the underlying Dispatcher or Task is deleted.

Waker s are most commonly created by Dispatcher s, which pass them into Task::Pend via its Context argument.

Member Function Documentation

◆ Clear()

void pw::async2::Waker::Clear ( )
inline

Clears this Waker.

After this call, Wake will no longer perform any action, and IsEmpty will return true.

This operation is guaranteed to be thread-safe.

◆ IsEmpty()

bool pw::async2::Waker::IsEmpty ( ) const

Returns whether this Waker is empty.

Empty wakers are those that perform no action upon wake. These may be created either via the default no-argument constructor or by calling Clear or std::move on a Waker, after which the moved-from Waker will be empty.

This operation is guaranteed to be thread-safe.

◆ operator=()

Waker & pw::async2::Waker::operator= ( Waker &&  other)
noexcept

Replace this Waker with another.

This operation is guaranteed to be thread-safe.

◆ Wake()

void pw::async2::Waker::Wake ( ) &&

Wakes up the Waker's creator, alerting it that an asynchronous event has occurred that may allow it to make progress.

Wake operates on an rvalue reference (&&) in order to indicate that the event that was waited on has been complete. This makes it possible to track the outstanding events that may cause a Task to wake up and make progress.

This operation is guaranteed to be thread-safe.


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