Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
d45a26ed
Commit
d45a26ed
authored
9 years ago
by
yang-g
Browse files
Options
Downloads
Patches
Plain Diff
allow null tag
parent
5239ee2b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/grpc++/server_context.h
+5
-1
5 additions, 1 deletion
include/grpc++/server_context.h
src/cpp/server/server_context.cc
+12
-4
12 additions, 4 deletions
src/cpp/server/server_context.cc
with
17 additions
and
5 deletions
include/grpc++/server_context.h
+
5
−
1
View file @
d45a26ed
...
...
@@ -128,7 +128,10 @@ class ServerContext {
// Async only. Has to be called before the rpc starts.
// Returns the tag in completion queue when the rpc finishes.
// IsCancelled() can then be called to check whether the rpc was cancelled.
void
AsyncNotifyWhenDone
(
void
*
tag
)
{
async_notify_when_done_tag_
=
tag
;
}
void
AsyncNotifyWhenDone
(
void
*
tag
)
{
has_notify_when_done_tag_
=
true
;
async_notify_when_done_tag_
=
tag
;
}
private
:
friend
class
::
grpc
::
testing
::
InteropContextInspector
;
...
...
@@ -170,6 +173,7 @@ class ServerContext {
void
set_call
(
grpc_call
*
call
);
CompletionOp
*
completion_op_
;
bool
has_notify_when_done_tag_
;
void
*
async_notify_when_done_tag_
;
gpr_timespec
deadline_
;
...
...
This diff is collapsed.
Click to expand it.
src/cpp/server/server_context.cc
+
12
−
4
View file @
d45a26ed
...
...
@@ -50,18 +50,22 @@ namespace grpc {
class
ServerContext
::
CompletionOp
GRPC_FINAL
:
public
CallOpSetInterface
{
public:
// initial refs: one in the server context, one in the cq
CompletionOp
()
:
refs_
(
2
),
finalized_
(
false
),
cancelled_
(
0
)
{}
CompletionOp
()
:
has_tag_
(
false
),
tag_
(
nullptr
),
refs_
(
2
),
finalized_
(
false
),
cancelled_
(
0
)
{}
void
FillOps
(
grpc_op
*
ops
,
size_t
*
nops
)
GRPC_OVERRIDE
;
bool
FinalizeResult
(
void
**
tag
,
bool
*
status
)
GRPC_OVERRIDE
;
bool
CheckCancelled
(
CompletionQueue
*
cq
);
void
set_tag
(
void
*
tag
)
{
tag_
=
tag
;
}
void
set_tag
(
void
*
tag
)
{
has_tag_
=
true
;
tag_
=
tag
;
}
void
Unref
();
private
:
bool
has_tag_
;
void
*
tag_
;
grpc
::
mutex
mu_
;
int
refs_
;
...
...
@@ -94,7 +98,7 @@ bool ServerContext::CompletionOp::FinalizeResult(void** tag, bool* status) {
grpc
::
unique_lock
<
grpc
::
mutex
>
lock
(
mu_
);
finalized_
=
true
;
bool
ret
=
false
;
if
(
tag_
)
{
if
(
has_
tag_
)
{
*
tag
=
tag_
;
ret
=
true
;
}
...
...
@@ -110,6 +114,7 @@ bool ServerContext::CompletionOp::FinalizeResult(void** tag, bool* status) {
ServerContext
::
ServerContext
()
:
completion_op_
(
nullptr
),
has_notify_when_done_tag_
(
false
),
async_notify_when_done_tag_
(
nullptr
),
call_
(
nullptr
),
cq_
(
nullptr
),
...
...
@@ -118,6 +123,7 @@ ServerContext::ServerContext()
ServerContext
::
ServerContext
(
gpr_timespec
deadline
,
grpc_metadata
*
metadata
,
size_t
metadata_count
)
:
completion_op_
(
nullptr
),
has_notify_when_done_tag_
(
false
),
async_notify_when_done_tag_
(
nullptr
),
deadline_
(
deadline
),
call_
(
nullptr
),
...
...
@@ -143,7 +149,9 @@ ServerContext::~ServerContext() {
void
ServerContext
::
BeginCompletionOp
(
Call
*
call
)
{
GPR_ASSERT
(
!
completion_op_
);
completion_op_
=
new
CompletionOp
();
completion_op_
->
set_tag
(
async_notify_when_done_tag_
);
if
(
has_notify_when_done_tag_
)
{
completion_op_
->
set_tag
(
async_notify_when_done_tag_
);
}
call
->
PerformOps
(
completion_op_
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment