Pigweed
C/C++ API Reference
Home
Modules
Loading...
Searching...
No Matches
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
25
namespace
internal {
26
31
[[nodiscard]]
bool
StoreWaker(Context& cx,
32
Waker& waker_out,
33
log::Token wait_reason);
34
35
}
// namespace internal
36
38
46
class
Context
{
47
public
:
50
Context
(
Dispatcher
&
dispatcher
,
Waker
& waker)
51
: dispatcher_(&
dispatcher
), waker_(&waker), requires_waker_(true) {}
52
57
Dispatcher
&
dispatcher
() {
return
*dispatcher_; }
58
73
void
ReEnqueue
();
74
79
PendingType
Unschedule
() {
80
requires_waker_ =
false
;
81
return
Pending
();
82
}
83
84
private
:
85
friend
class
Task
;
86
friend
bool
internal::StoreWaker(
Context
& cx,
87
Waker
& waker_out,
88
log::Token wait_reason);
89
90
Dispatcher
* dispatcher_;
91
Waker
* waker_;
92
bool
requires_waker_;
93
};
94
96
97
}
// namespace pw::async2
pw::async2::Context
Definition:
context.h:46
pw::async2::Context::Unschedule
PendingType Unschedule()
Definition:
context.h:79
pw::async2::Context::ReEnqueue
void ReEnqueue()
pw::async2::Context::Context
Context(Dispatcher &dispatcher, Waker &waker)
Definition:
context.h:50
pw::async2::Context::dispatcher
Dispatcher & dispatcher()
Definition:
context.h:57
pw::async2::Dispatcher
Definition:
dispatcher.h:46
pw::async2::Task
Definition:
task.h:67
pw::async2::Waker
Definition:
waker.h:158
pw::async2::Pending
constexpr PendingType Pending()
Returns a value indicating that an operation was not yet able to complete.
Definition:
poll.h:353
pw::async2::PendingType
Definition:
poll.h:52
pw_async2
public
pw_async2
context.h
Generated by
1.9.6