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
48db18f9
Commit
48db18f9
authored
9 years ago
by
Craig Tiller
Browse files
Options
Downloads
Patches
Plain Diff
stream_op cleanup: iomgr closure, executor changes
parent
577c9b2f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/core/iomgr/closure.c
+8
-15
8 additions, 15 deletions
src/core/iomgr/closure.c
src/core/iomgr/closure.h
+8
-11
8 additions, 11 deletions
src/core/iomgr/closure.h
src/core/iomgr/executor.c
+4
-9
4 additions, 9 deletions
src/core/iomgr/executor.c
with
20 additions
and
35 deletions
src/core/iomgr/closure.c
+
8
−
15
View file @
48db18f9
...
...
@@ -39,18 +39,17 @@ void grpc_closure_init(grpc_closure *closure, grpc_iomgr_cb_func cb,
void
*
cb_arg
)
{
closure
->
cb
=
cb
;
closure
->
cb_arg
=
cb_arg
;
closure
->
next
=
NULL
;
closure
->
final_data
=
0
;
}
void
grpc_closure_list_add
(
grpc_closure_list
*
closure_list
,
grpc_closure
*
closure
,
int
success
)
{
if
(
closure
==
NULL
)
return
;
closure
->
next
=
NULL
;
closure
->
success
=
success
;
closure
->
final_data
=
(
success
!=
0
);
if
(
closure_list
->
head
==
NULL
)
{
closure_list
->
head
=
closure
;
}
else
{
closure_list
->
tail
->
next
=
closure
;
closure_list
->
tail
->
final_data
|=
(
gpr_uintptr
)
closure
;
}
closure_list
->
tail
=
closure
;
}
...
...
@@ -66,22 +65,12 @@ void grpc_closure_list_move(grpc_closure_list *src, grpc_closure_list *dst) {
if
(
dst
->
head
==
NULL
)
{
*
dst
=
*
src
;
}
else
{
dst
->
tail
->
next
=
src
->
head
;
dst
->
tail
->
final_data
|=
(
gpr_uintptr
)
src
->
head
;
dst
->
tail
=
src
->
tail
;
}
src
->
head
=
src
->
tail
=
NULL
;
}
grpc_closure
*
grpc_closure_list_pop
(
grpc_closure_list
*
list
)
{
grpc_closure
*
head
;
if
(
list
->
head
==
NULL
)
{
return
NULL
;
}
head
=
list
->
head
;
list
->
head
=
list
->
head
->
next
;
return
head
;
}
typedef
struct
{
grpc_iomgr_cb_func
cb
;
void
*
cb_arg
;
...
...
@@ -103,3 +92,7 @@ grpc_closure *grpc_closure_create(grpc_iomgr_cb_func cb, void *cb_arg) {
grpc_closure_init
(
&
wc
->
wrapper
,
closure_wrapper
,
wc
);
return
&
wc
->
wrapper
;
}
grpc_closure
*
grpc_closure_next
(
grpc_closure
*
closure
)
{
return
(
grpc_closure
*
)(
closure
->
final_data
&
~
(
gpr_uintptr
)
1
);
}
This diff is collapsed.
Click to expand it.
src/core/iomgr/closure.h
+
8
−
11
View file @
48db18f9
...
...
@@ -34,7 +34,7 @@
#ifndef GRPC_INTERNAL_CORE_IOMGR_CLOSURE_H
#define GRPC_INTERNAL_CORE_IOMGR_CLOSURE_H
#include
<
stddef
.h>
#include
<
grpc/support/port_platform
.h>
struct
grpc_closure
;
typedef
struct
grpc_closure
grpc_closure
;
...
...
@@ -64,13 +64,10 @@ struct grpc_closure {
/** Arguments to be passed to "cb". */
void
*
cb_arg
;
/** Internal. A boolean indication to "cb" on the state of the iomgr.
* For instance, closures created during a shutdown would have this field set
* to false. */
int
success
;
/**< Internal. Do not touch */
struct
grpc_closure
*
next
;
/** Once enqueued, contains in the lower bit the success of the closure,
and in the upper bits the pointer to the next closure in the list.
Before enqueing for execution, this is usable for scratch data. */
gpr_uintptr
final_data
;
};
/** Initializes \a closure with \a cb and \a cb_arg. */
...
...
@@ -91,10 +88,10 @@ void grpc_closure_list_add(grpc_closure_list *list, grpc_closure *closure,
/** append all closures from \a src to \a dst and empty \a src. */
void
grpc_closure_list_move
(
grpc_closure_list
*
src
,
grpc_closure_list
*
dst
);
/** pop (return and remove) the head closure from \a list. */
grpc_closure
*
grpc_closure_list_pop
(
grpc_closure_list
*
list
);
/** return whether \a list is empty. */
int
grpc_closure_list_empty
(
grpc_closure_list
list
);
/** return the next pointer for a queued closure list */
grpc_closure
*
grpc_closure_next
(
grpc_closure
*
closure
);
#endif
/* GRPC_INTERNAL_CORE_IOMGR_CLOSURE_H */
This diff is collapsed.
Click to expand it.
src/core/iomgr/executor.c
+
4
−
9
View file @
48db18f9
...
...
@@ -63,8 +63,6 @@ void grpc_executor_init() {
/* thread body */
static
void
closure_exec_thread_func
(
void
*
ignored
)
{
grpc_closure
*
closure
;
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
while
(
1
)
{
gpr_mu_lock
(
&
g_executor
.
mu
);
...
...
@@ -72,16 +70,16 @@ static void closure_exec_thread_func(void *ignored) {
gpr_mu_unlock
(
&
g_executor
.
mu
);
break
;
}
closure
=
grpc_closure_list_pop
(
&
g_executor
.
closures
);
if
(
closure
==
NULL
)
{
if
(
grpc_closure_list_empty
(
g_executor
.
closures
))
{
/* no more work, time to die */
GPR_ASSERT
(
g_executor
.
busy
==
1
);
g_executor
.
busy
=
0
;
gpr_mu_unlock
(
&
g_executor
.
mu
);
break
;
}
else
{
grpc_exec_ctx_enqueue_list
(
&
exec_ctx
,
&
g_executor
.
closures
);
}
gpr_mu_unlock
(
&
g_executor
.
mu
);
closure
->
cb
(
&
exec_ctx
,
closure
->
cb_arg
,
closure
->
success
);
grpc_exec_ctx_flush
(
&
exec_ctx
);
}
grpc_exec_ctx_finish
(
&
exec_ctx
);
...
...
@@ -125,7 +123,6 @@ void grpc_executor_enqueue(grpc_closure *closure, int success) {
void
grpc_executor_shutdown
()
{
int
pending_join
;
grpc_closure
*
closure
;
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
gpr_mu_lock
(
&
g_executor
.
mu
);
...
...
@@ -136,9 +133,7 @@ void grpc_executor_shutdown() {
* list below because we aren't accepting new work */
/* Execute pending callbacks, some may be performing cleanups */
while
((
closure
=
grpc_closure_list_pop
(
&
g_executor
.
closures
))
!=
NULL
)
{
closure
->
cb
(
&
exec_ctx
,
closure
->
cb_arg
,
closure
->
success
);
}
grpc_exec_ctx_enqueue_list
(
&
exec_ctx
,
&
g_executor
.
closures
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
GPR_ASSERT
(
grpc_closure_list_empty
(
g_executor
.
closures
));
if
(
pending_join
)
{
...
...
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