Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
z
Enumerations
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
z
Classes
Class List
Class Hierarchy
Class Members
All
:
[
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
[
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
Enumerations
a
b
c
d
e
f
h
i
k
l
m
n
o
p
r
s
t
u
v
w
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
Properties
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Related Functions
:
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
grpc
src
core
lib
promise
wait_set.h
Go to the documentation of this file.
1
// Copyright 2021 gRPC authors.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://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,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#ifndef GRPC_CORE_LIB_PROMISE_WAIT_SET_H
16
#define GRPC_CORE_LIB_PROMISE_WAIT_SET_H
17
18
#include <
grpc/support/port_platform.h
>
19
20
#include <utility>
21
22
#include "absl/container/flat_hash_set.h"
23
#include "absl/hash/hash.h"
24
25
#include "
src/core/lib/promise/activity.h
"
26
#include "
src/core/lib/promise/poll.h
"
27
28
namespace
grpc_core
{
29
30
// Helper type that can be used to enqueue many Activities waiting for some
31
// external state.
32
// Typically the external state should be guarded by mu_, and a call to
33
// WakeAllAndUnlock should be made when the state changes.
34
// Promises should bottom out polling inside pending(), which will register for
35
// wakeup and return Pending().
36
// Queues handles to Activities, and not Activities themselves, meaning that if
37
// an Activity is destroyed prior to wakeup we end up holding only a small
38
// amount of memory (around 16 bytes + malloc overhead) until the next wakeup
39
// occurs.
40
class
WaitSet
final {
41
using
WakerSet
=
absl::flat_hash_set<Waker>
;
42
43
public
:
44
// Register for wakeup, return Pending(). If state is not ready to proceed,
45
// Promises should bottom out here.
46
Pending
AddPending
(
Waker
waker) {
47
pending_
.
emplace
(
std::move
(waker));
48
return
Pending
();
49
}
50
51
class
WakeupSet
{
52
public
:
53
void
Wakeup
() {
54
while
(!
wakeup_
.
empty
()) {
55
wakeup_
.
extract
(
wakeup_
.
begin
()).
value
().Wakeup();
56
}
57
}
58
59
private
:
60
friend
class
WaitSet
;
61
explicit
WakeupSet
(
WakerSet
&& wakeup)
62
:
wakeup_
(
std
::
forward
<
WakerSet
>(wakeup)) {}
63
WakerSet
wakeup_
;
64
};
65
66
GRPC_MUST_USE_RESULT
WakeupSet
TakeWakeupSet
() {
67
return
WakeupSet
(
std::move
(
pending_
));
68
}
69
70
private
:
71
// Handles to activities that need to be awoken.
72
WakerSet
pending_
;
73
};
74
75
}
// namespace grpc_core
76
77
#endif // GRPC_CORE_LIB_PROMISE_WAIT_SET_H
absl::container_internal::raw_hash_set::extract
node_type extract(const_iterator position)
Definition:
abseil-cpp/absl/container/internal/raw_hash_set.h:1633
grpc_core::WaitSet::WakeupSet
Definition:
wait_set.h:51
grpc_core::WaitSet::WakeupSet::wakeup_
WakerSet wakeup_
Definition:
wait_set.h:63
grpc_core::WaitSet::TakeWakeupSet
GRPC_MUST_USE_RESULT WakeupSet TakeWakeupSet()
Definition:
wait_set.h:66
grpc_core
Definition:
call_metric_recorder.h:31
grpc_core::WaitSet::AddPending
Pending AddPending(Waker waker)
Definition:
wait_set.h:46
absl::container_internal::raw_hash_set::begin
iterator begin()
Definition:
abseil-cpp/absl/container/internal/raw_hash_set.h:1327
grpc_core::WaitSet::WakeupSet::Wakeup
void Wakeup()
Definition:
wait_set.h:53
grpc_core::Pending
Definition:
poll.h:29
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition:
abseil-cpp/absl/utility/utility.h:221
grpc_core::WaitSet::pending_
WakerSet pending_
Definition:
wait_set.h:72
grpc_core::WaitSet
Definition:
wait_set.h:40
absl::container_internal::raw_hash_set::emplace
std::pair< iterator, bool > emplace(Args &&... args)
Definition:
abseil-cpp/absl/container/internal/raw_hash_set.h:1484
absl::flat_hash_set< Waker >
absl::container_internal::raw_hash_set::empty
bool empty() const
Definition:
abseil-cpp/absl/container/internal/raw_hash_set.h:1341
grpc_core::WaitSet::WakeupSet::WakeupSet
WakeupSet(WakerSet &&wakeup)
Definition:
wait_set.h:61
GRPC_MUST_USE_RESULT
#define GRPC_MUST_USE_RESULT
Definition:
impl/codegen/port_platform.h:584
grpc_core::Waker
Definition:
activity.h:61
poll.h
std
Definition:
grpcpp/impl/codegen/async_unary_call.h:407
absl::container_internal::node_handle::value
value_type & value() const
Definition:
abseil-cpp/absl/container/internal/common.h:128
absl::forward
constexpr T && forward(absl::remove_reference_t< T > &t) noexcept
Definition:
abseil-cpp/absl/utility/utility.h:230
activity.h
port_platform.h
grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:51