Pigweed
 
Loading...
Searching...
No Matches
pw::async2::Waker Class Reference

#include <dispatcher_base.h>

Public Member Functions

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

Friends

class Task
 
class NativeDispatcherBase
 

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.

◆ InternalCloneInto()

void pw::async2::Waker::InternalCloneInto ( Waker waker_out) &

INTERNAL-ONLY: users should use the PW_ASYNC_CLONE_WAKER macro.

Creates a second Waker from this Waker.

Clone is made explicit in order to allow for easier tracking of the different Wakers that may wake up a Task.

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: