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
7a4e5b42
Commit
7a4e5b42
authored
8 years ago
by
Sree Kuchibhotla
Browse files
Options
Downloads
Patches
Plain Diff
Completion queue creation API change (JUST API change. No functionality change)
parent
a35d0e38
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/grpc/grpc.h
+43
-1
43 additions, 1 deletion
include/grpc/grpc.h
src/core/lib/surface/completion_queue.c
+22
-5
22 additions, 5 deletions
src/core/lib/surface/completion_queue.c
with
65 additions
and
6 deletions
include/grpc/grpc.h
+
43
−
1
View file @
7a4e5b42
...
...
@@ -93,9 +93,51 @@ GRPCAPI const char *grpc_version_string(void);
/** Return a string specifying what the 'g' in gRPC stands for */
GRPCAPI
const
char
*
grpc_g_stands_for
(
void
);
/** Create a completion queue */
/** Specifies the type of APIs to use to pop events from the completion queue */
typedef
enum
{
/** Events are popped out by calling grpc_completion_queue_next() API ONLY */
GRPC_CQ_NEXT
=
1
,
/** Events are popped out by calling grpc_completion_queue_pluck() API ONLY*/
GRPC_CQ_PLUCK
}
grpc_cq_completion_type
;
/** Completion queues internally MAY maintain a set of file descriptors in a
structure called 'pollset'. This enum specifies if a completion queue has an
associated pollset and any restrictions on the type of file descriptors that
can be present in the pollset.
I/O progress can only be made when grpc_completion_queue_next() or
grpc_completion_queue_pluck() are called on the completion queue (unless the
grpc_cq_polling_type is NON_POLLING) and hence it is very important to
actively call these APIs */
typedef
enum
{
/** The completion queue will have an associated pollset and there is no
restriction on the type of file descriptors the pollset may contain */
DEFAULT_POLLING
,
/** Similar to DEFAULT_POLLING except that the completion queues will not
contain any 'listening file descriptors' (i.e file descriptors used to
listen to incoming channels */
NON_LISTENING
,
/** The completion queue will not have an associated pollset. Note that
grpc_completion_queue_next() or grpc_completion_queue_pluck() MUST still
be called to pop events from the completion queue; it is not required to
call them actively to make I/O progress */
NON_POLLING
}
grpc_cq_polling_type
;
/** Create a completion queue.
WARNING: This API is deprecated and will soon be deleted and replaced with
completion_queue_create_ex() */
GRPCAPI
grpc_completion_queue
*
grpc_completion_queue_create
(
void
*
reserved
);
/** Create a completion queue */
GRPCAPI
grpc_completion_queue
*
grpc_completion_queue_create_ex
(
grpc_cq_completion_type
completion_type
,
grpc_cq_polling_type
polling_type
,
void
*
reserved
);
/** Blocks until an event is available, the completion queue is being shut down,
or deadline is reached.
...
...
This diff is collapsed.
Click to expand it.
src/core/lib/surface/completion_queue.c
+
22
−
5
View file @
7a4e5b42
...
...
@@ -64,6 +64,10 @@ typedef struct {
struct
grpc_completion_queue
{
/** owned by pollset */
gpr_mu
*
mu
;
grpc_cq_completion_type
completion_type
;
grpc_cq_polling_type
polling_type
;
/** completed events */
grpc_cq_completion
completed_head
;
grpc_cq_completion
*
completed_tail
;
...
...
@@ -79,6 +83,7 @@ struct grpc_completion_queue {
int
shutdown_called
;
int
is_server_cq
;
/** Can the server cq accept incoming channels */
/* TODO: sreek - This will no longer be needed. Use polling_type set */
int
is_non_listening_server_cq
;
int
num_pluckers
;
plucker
pluckers
[
GRPC_MAX_COMPLETION_QUEUE_PLUCKERS
];
...
...
@@ -110,7 +115,9 @@ int grpc_cq_event_timeout_trace;
static
void
on_pollset_shutdown_done
(
grpc_exec_ctx
*
exec_ctx
,
void
*
cc
,
grpc_error
*
error
);
grpc_completion_queue
*
grpc_completion_queue_create
(
void
*
reserved
)
{
grpc_completion_queue
*
grpc_completion_queue_create_ex
(
grpc_cq_completion_type
completion_type
,
grpc_cq_polling_type
polling_type
,
void
*
reserved
)
{
grpc_completion_queue
*
cc
;
GPR_ASSERT
(
!
reserved
);
...
...
@@ -148,6 +155,10 @@ grpc_completion_queue *grpc_completion_queue_create(void *reserved) {
return
cc
;
}
grpc_completion_queue
*
grpc_completion_queue_create
(
void
*
reserved
)
{
return
grpc_completion_queue_create_ex
(
0
,
DEFAULT_POLLING
,
reserved
);
}
#ifdef GRPC_CQ_REF_COUNT_DEBUG
void
grpc_cq_internal_ref
(
grpc_completion_queue
*
cc
,
const
char
*
reason
,
const
char
*
file
,
int
line
)
{
...
...
@@ -356,8 +367,9 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc,
"deadline=gpr_timespec { tv_sec: %"
PRId64
", tv_nsec: %d, clock_type: %d }, "
"reserved=%p)"
,
5
,
(
cc
,
deadline
.
tv_sec
,
deadline
.
tv_nsec
,
(
int
)
deadline
.
clock_type
,
reserved
));
5
,
(
cc
,
deadline
.
tv_sec
,
deadline
.
tv_nsec
,
(
int
)
deadline
.
clock_type
,
reserved
));
GPR_ASSERT
(
!
reserved
);
dump_pending_tags
(
cc
);
...
...
@@ -524,8 +536,9 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag,
"deadline=gpr_timespec { tv_sec: %"
PRId64
", tv_nsec: %d, clock_type: %d }, "
"reserved=%p)"
,
6
,
(
cc
,
tag
,
deadline
.
tv_sec
,
deadline
.
tv_nsec
,
(
int
)
deadline
.
clock_type
,
reserved
));
6
,
(
cc
,
tag
,
deadline
.
tv_sec
,
deadline
.
tv_nsec
,
(
int
)
deadline
.
clock_type
,
reserved
));
}
GPR_ASSERT
(
!
reserved
);
...
...
@@ -681,10 +694,14 @@ grpc_completion_queue *grpc_cq_from_pollset(grpc_pollset *ps) {
}
void
grpc_cq_mark_non_listening_server_cq
(
grpc_completion_queue
*
cc
)
{
/* TODO: sreek - use cc->polling_type field here and add a validation check
(i.e grpc_cq_mark_non_listening_server_cq can only be called on a cc whose
polling_type is set to NON_LISTENING */
cc
->
is_non_listening_server_cq
=
1
;
}
bool
grpc_cq_is_non_listening_server_cq
(
grpc_completion_queue
*
cc
)
{
/* TODO (sreek) - return (cc->polling_type == NON_LISTENING) */
return
(
cc
->
is_non_listening_server_cq
==
1
);
}
...
...
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