Pigweed
C/C++ API Reference
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
pw_async2
public
pw_async2
context.h
1
// Copyright 2025 The Pigweed Authors
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
4
// use this file except in compliance with the License. You may obtain a copy of
5
// the License at
6
//
7
// https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
// License for the specific language governing permissions and limitations under
13
// the License.
14
#pragma once
15
16
#include "pw_async2/poll.h"
17
#include "pw_async2/waker.h"
18
#include "pw_log/tokenized_args.h"
19
20
namespace
pw::async2 {
21
22
class
Context;
23
class
Dispatcher;
24
class
NativeDispatcherBase;
25
26
namespace
internal {
27
28
class
WakerQueueBase;
29
34
bool
StoreWaker(Context& cx, Waker& waker_out, log::Token wait_reason);
35
36
// Overload of StoreWaker taking a queue, allowing PW_ASYNC_STORE_WAKER to be
37
// used with a WakerQueue as the target.
38
bool
StoreWaker(Context& cx, WakerQueueBase& queue, log::Token wait_reason);
39
40
}
// namespace internal
41
49
class
Context
{
50
public
:
53
Context
(
Dispatcher
&
dispatcher
,
Waker
& waker)
54
: dispatcher_(&
dispatcher
), waker_(&waker), requires_waker_(true) {}
55
60
Dispatcher
&
dispatcher
() {
return
*dispatcher_; }
61
76
void
ReEnqueue
();
77
80
// removed from the dispatcher, requiring it to be manually re-posted to run
81
// again.
82
template
<
typename
T = ReadyType>
83
Poll<T>
Unschedule
() {
84
requires_waker_ =
false
;
85
return
Pending();
86
}
87
88
private
:
89
friend
class
NativeDispatcherBase
;
90
friend
bool
internal::StoreWaker(
Context
& cx,
91
Waker
& waker_out,
92
log::Token wait_reason);
93
friend
bool
internal::StoreWaker(
Context
& cx,
94
internal::WakerQueueBase
& queue,
95
log::Token wait_reason);
96
97
Dispatcher
* dispatcher_;
98
Waker
* waker_;
99
bool
requires_waker_;
100
};
101
102
}
// namespace pw::async2
pw::async2::Context
Definition:
context.h:49
pw::async2::Context::ReEnqueue
void ReEnqueue()
pw::async2::Context::Unschedule
Poll< T > Unschedule()
Definition:
context.h:83
pw::async2::Context::Context
Context(Dispatcher &dispatcher, Waker &waker)
Definition:
context.h:53
pw::async2::Context::dispatcher
Dispatcher & dispatcher()
Definition:
context.h:60
pw::async2::Dispatcher
A single-threaded cooperatively-scheduled runtime for async tasks.
Definition:
dispatcher.h:46
pw::async2::NativeDispatcherBase
Definition:
dispatcher_base.h:47
pw::async2::Poll
Definition:
poll.h:54
pw::async2::Waker
Definition:
waker.h:148
pw::async2::internal::WakerQueueBase
Definition:
waker_queue.h:23
Generated by
1.9.6