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
channel
call_finalization.h
Go to the documentation of this file.
1
// Copyright 2022 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_CHANNEL_CALL_FINALIZATION_H
16
#define GRPC_CORE_LIB_CHANNEL_CALL_FINALIZATION_H
17
18
#include <
grpc/support/port_platform.h
>
19
20
#include <utility>
21
22
#include "absl/utility/utility.h"
23
24
#include "
src/core/lib/channel/channel_stack.h
"
25
#include "
src/core/lib/promise/context.h
"
26
#include "
src/core/lib/resource_quota/arena.h
"
27
28
namespace
grpc_core
{
29
30
// Call finalization context.
31
// Sometimes a filter needs to perform some operation after the last byte of
32
// data is flushed to the wire. This context is used to perform that
33
// finalization.
34
// Filters can register a finalizer by calling Add().
35
// The finalizer will be called before the call is destroyed but after
36
// the top level promise is completed.
37
class
CallFinalization
{
38
public
:
39
// Add a step to the finalization context.
40
// Takes a callable with a signature compatible with:
41
// (const grpc_call_final_info&) -> void.
42
// Finalizers are run in the reverse order they are added.
43
template
<
typename
F>
44
void
Add
(F&& t) {
45
first_
=
46
GetContext<Arena>()->New<
FuncFinalizer<F>
>(std::forward<F>(t),
first_
);
47
}
48
49
void
Run
(
const
grpc_call_final_info
* final_info) {
50
if
(
Finalizer
* f =
absl::exchange
(
first_
,
nullptr
)) f->Run(final_info);
51
}
52
53
private
:
54
// Base class for finalizer implementations.
55
class
Finalizer
{
56
public
:
57
// Run the finalizer and call the destructor of this Finalizer.
58
virtual
void
Run
(
const
grpc_call_final_info
* final_info) = 0;
59
60
protected
:
61
~Finalizer
() {}
62
};
63
// Specialization for callable objects.
64
template
<
typename
F>
65
class
FuncFinalizer
final :
public
Finalizer
{
66
public
:
67
FuncFinalizer
(F&& f,
Finalizer
*
next
)
68
:
next_
(
next
),
f_
(
std
::
forward
<
F
>(f)) {}
69
70
void
Run
(
const
grpc_call_final_info
* final_info)
override
{
71
f_
(final_info);
72
Finalizer
*
next
=
next_
;
73
this->~
FuncFinalizer
();
74
if
(
next
!=
nullptr
)
next
->Run(final_info);
75
}
76
77
private
:
78
Finalizer
*
next_
;
79
F
f_
;
80
};
81
// The first finalizer in the chain.
82
Finalizer
*
first_
=
nullptr
;
83
};
84
85
template
<>
86
struct
ContextType
<
CallFinalization
> {};
87
88
}
// namespace grpc_core
89
90
#endif // GRPC_CORE_LIB_CHANNEL_CALL_FINALIZATION_H
grpc_core::CallFinalization::FuncFinalizer::Run
void Run(const grpc_call_final_info *final_info) override
Definition:
call_finalization.h:70
grpc_core::CallFinalization::FuncFinalizer::next_
Finalizer * next_
Definition:
call_finalization.h:78
grpc_core::CallFinalization::FuncFinalizer::FuncFinalizer
FuncFinalizer(F &&f, Finalizer *next)
Definition:
call_finalization.h:67
grpc_core
Definition:
call_metric_recorder.h:31
grpc_core::CallFinalization::Add
void Add(F &&t)
Definition:
call_finalization.h:44
grpc_core::CallFinalization::first_
Finalizer * first_
Definition:
call_finalization.h:82
arena.h
grpc_core::ContextType
Definition:
core/lib/promise/context.h:32
channel_stack.h
grpc_core::CallFinalization::Run
void Run(const grpc_call_final_info *final_info)
Definition:
call_finalization.h:49
F
#define F(b, c, d)
Definition:
md4.c:112
grpc_core::CallFinalization
Definition:
call_finalization.h:37
grpc_core::CallFinalization::Finalizer::~Finalizer
~Finalizer()
Definition:
call_finalization.h:61
next
AllocList * next[kMaxLevel]
Definition:
abseil-cpp/absl/base/internal/low_level_alloc.cc:100
std
Definition:
grpcpp/impl/codegen/async_unary_call.h:407
grpc_core::CallFinalization::FuncFinalizer
Definition:
call_finalization.h:65
context.h
grpc_core::CallFinalization::Finalizer::Run
virtual void Run(const grpc_call_final_info *final_info)=0
grpc_call_final_info
Definition:
channel_stack.h:95
absl::forward
constexpr T && forward(absl::remove_reference_t< T > &t) noexcept
Definition:
abseil-cpp/absl/utility/utility.h:230
grpc_core::CallFinalization::FuncFinalizer::f_
F f_
Definition:
call_finalization.h:79
grpc_core::CallFinalization::Finalizer
Definition:
call_finalization.h:55
absl::exchange
T exchange(T &obj, U &&new_value)
Definition:
abseil-cpp/absl/utility/utility.h:314
port_platform.h
grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:42