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
cpp
server
src/cpp/server/server_callback.cc
Go to the documentation of this file.
1
/*
2
* Copyright 2019 gRPC authors.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*
16
*/
17
18
#include <
grpcpp/impl/codegen/server_callback.h
>
19
#include <
grpcpp/support/server_callback.h
>
20
21
#include "
src/core/lib/iomgr/closure.h
"
22
#include "
src/core/lib/iomgr/error.h
"
23
#include "
src/core/lib/iomgr/exec_ctx.h
"
24
#include "
src/core/lib/iomgr/executor.h
"
25
26
namespace
grpc
{
27
namespace
internal
{
28
29
void
ServerCallbackCall::ScheduleOnDone
(
bool
inline_ondone) {
30
if
(inline_ondone) {
31
CallOnDone
();
32
}
else
{
33
// Unlike other uses of closure, do not Ref or Unref here since at this
34
// point, all the Ref'fing and Unref'fing is done for this call.
35
grpc_core::ExecCtx
exec_ctx
;
36
struct
ClosureWithArg {
37
grpc_closure
closure
;
38
ServerCallbackCall
*
call
;
39
explicit
ClosureWithArg(
ServerCallbackCall
* call_arg) :
call
(call_arg) {
40
GRPC_CLOSURE_INIT
(
41
&
closure
,
42
[](
void
* void_arg,
grpc_error_handle
) {
43
ClosureWithArg*
arg
=
static_cast<
ClosureWithArg*
>
(void_arg);
44
arg
->call->CallOnDone();
45
delete
arg
;
46
},
47
this
, grpc_schedule_on_exec_ctx);
48
}
49
};
50
ClosureWithArg*
arg
=
new
ClosureWithArg(
this
);
51
grpc_core::Executor::Run
(&
arg
->closure,
GRPC_ERROR_NONE
);
52
}
53
}
54
55
void
ServerCallbackCall::CallOnCancel
(
ServerReactor
* reactor) {
56
if
(
reactor
->
InternalInlineable
()) {
57
reactor
->
OnCancel
();
58
}
else
{
59
// Ref to make sure that the closure executes before the whole call gets
60
// destructed, and Unref within the closure.
61
Ref
();
62
grpc_core::ExecCtx
exec_ctx
;
63
struct
ClosureWithArg {
64
grpc_closure
closure
;
65
ServerCallbackCall
*
call
;
66
ServerReactor
*
reactor
;
67
ClosureWithArg(
ServerCallbackCall
* call_arg,
ServerReactor
* reactor_arg)
68
:
call
(call_arg),
reactor
(reactor_arg) {
69
GRPC_CLOSURE_INIT
(
70
&
closure
,
71
[](
void
* void_arg,
grpc_error_handle
) {
72
ClosureWithArg*
arg
=
static_cast<
ClosureWithArg*
>
(void_arg);
73
arg
->reactor->OnCancel();
74
arg
->call->MaybeDone();
75
delete
arg
;
76
},
77
this
, grpc_schedule_on_exec_ctx);
78
}
79
};
80
ClosureWithArg*
arg
=
new
ClosureWithArg(
this
,
reactor
);
81
grpc_core::Executor::Run
(&
arg
->closure,
GRPC_ERROR_NONE
);
82
}
83
}
84
85
}
// namespace internal
86
}
// namespace grpc
GRPC_CLOSURE_INIT
#define GRPC_CLOSURE_INIT(closure, cb, cb_arg, scheduler)
Definition:
closure.h:115
GRPC_ERROR_NONE
#define GRPC_ERROR_NONE
Definition:
error.h:234
grpc
Definition:
grpcpp/alarm.h:33
grpc::internal::ServerReactor::InternalInlineable
virtual bool InternalInlineable()
Definition:
impl/codegen/server_callback.h:61
grpc::internal::ServerCallbackCall
The base class of ServerCallbackUnary etc.
Definition:
impl/codegen/server_callback.h:75
closure.h
server_callback.h
grpc::internal::ServerCallbackCall::reactor
virtual ServerReactor * reactor()=0
grpc_core::Executor::Run
static void Run(grpc_closure *closure, grpc_error_handle error, ExecutorType executor_type=ExecutorType::DEFAULT, ExecutorJobType job_type=ExecutorJobType::SHORT)
Definition:
executor.cc:398
grpc::internal::ServerCallbackCall::CallOnDone
virtual void CallOnDone()=0
call
FilterStackCall * call
Definition:
call.cc:750
grpc::internal::ServerReactor::OnCancel
virtual void OnCancel()=0
grpc::internal::ServerCallbackCall::Ref
void Ref()
Increases the reference count.
Definition:
impl/codegen/server_callback.h:127
grpc::internal::ServerReactor
Definition:
impl/codegen/server_callback.h:51
closure
grpc_closure closure
Definition:
src/core/lib/surface/server.cc:466
grpc::internal::ServerCallbackCall::ScheduleOnDone
void ScheduleOnDone(bool inline_ondone)
Definition:
src/cpp/server/server_callback.cc:29
arg
Definition:
cmdline.cc:40
error.h
grpc_core::ExecCtx
Definition:
exec_ctx.h:97
executor.h
server_callback.h
exec_ctx
grpc_core::ExecCtx exec_ctx
Definition:
end2end_binder_transport_test.cc:75
arg
struct arg arg
exec_ctx.h
closure
Definition:
proxy.cc:59
internal
Definition:
benchmark/test/output_test_helper.cc:20
grpc_error
Definition:
error_internal.h:42
grpc_closure
Definition:
closure.h:56
grpc::internal::ServerCallbackCall::CallOnCancel
void CallOnCancel(ServerReactor *reactor)
Definition:
src/cpp/server/server_callback.cc:55
grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:17