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
420effac
Commit
420effac
authored
9 years ago
by
Yang Gao
Browse files
Options
Downloads
Plain Diff
Merge pull request #4376 from ctiller/wqtest
Cover more of workqueue
parents
5028de77
97b51c06
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
src/core/iomgr/workqueue_posix.c
+3
-0
3 additions, 0 deletions
src/core/iomgr/workqueue_posix.c
test/core/iomgr/workqueue_test.c
+36
-0
36 additions, 0 deletions
test/core/iomgr/workqueue_test.c
with
39 additions
and
0 deletions
src/core/iomgr/workqueue_posix.c
+
3
−
0
View file @
420effac
...
...
@@ -103,6 +103,9 @@ void grpc_workqueue_add_to_pollset(grpc_exec_ctx *exec_ctx,
void
grpc_workqueue_flush
(
grpc_exec_ctx
*
exec_ctx
,
grpc_workqueue
*
workqueue
)
{
gpr_mu_lock
(
&
workqueue
->
mu
);
if
(
grpc_closure_list_empty
(
workqueue
->
closure_list
))
{
grpc_wakeup_fd_wakeup
(
&
workqueue
->
wakeup_fd
);
}
grpc_closure_list_move
(
&
exec_ctx
->
closure_list
,
&
workqueue
->
closure_list
);
gpr_mu_unlock
(
&
workqueue
->
mu
);
}
...
...
This diff is collapsed.
Click to expand it.
test/core/iomgr/workqueue_test.c
+
36
−
0
View file @
420effac
...
...
@@ -48,6 +48,15 @@ static void must_succeed(grpc_exec_ctx *exec_ctx, void *p, int success) {
gpr_mu_unlock
(
GRPC_POLLSET_MU
(
&
g_pollset
));
}
static
void
test_ref_unref
(
void
)
{
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
grpc_workqueue
*
wq
=
grpc_workqueue_create
(
&
exec_ctx
);
GRPC_WORKQUEUE_REF
(
wq
,
"test"
);
GRPC_WORKQUEUE_UNREF
(
&
exec_ctx
,
wq
,
"test"
);
GRPC_WORKQUEUE_UNREF
(
&
exec_ctx
,
wq
,
"destroy"
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
}
static
void
test_add_closure
(
void
)
{
grpc_closure
c
;
int
done
=
0
;
...
...
@@ -72,6 +81,31 @@ static void test_add_closure(void) {
grpc_exec_ctx_finish
(
&
exec_ctx
);
}
static
void
test_flush
(
void
)
{
grpc_closure
c
;
int
done
=
0
;
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
grpc_workqueue
*
wq
=
grpc_workqueue_create
(
&
exec_ctx
);
gpr_timespec
deadline
=
GRPC_TIMEOUT_SECONDS_TO_DEADLINE
(
5
);
grpc_pollset_worker
worker
;
grpc_closure_init
(
&
c
,
must_succeed
,
&
done
);
grpc_exec_ctx_enqueue
(
&
exec_ctx
,
&
c
,
1
);
grpc_workqueue_flush
(
&
exec_ctx
,
wq
);
grpc_workqueue_add_to_pollset
(
&
exec_ctx
,
wq
,
&
g_pollset
);
gpr_mu_lock
(
GRPC_POLLSET_MU
(
&
g_pollset
));
GPR_ASSERT
(
!
done
);
grpc_pollset_work
(
&
exec_ctx
,
&
g_pollset
,
&
worker
,
gpr_now
(
deadline
.
clock_type
),
deadline
);
gpr_mu_unlock
(
GRPC_POLLSET_MU
(
&
g_pollset
));
grpc_exec_ctx_finish
(
&
exec_ctx
);
GPR_ASSERT
(
done
);
GRPC_WORKQUEUE_UNREF
(
&
exec_ctx
,
wq
,
"destroy"
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
}
static
void
destroy_pollset
(
grpc_exec_ctx
*
exec_ctx
,
void
*
p
,
int
success
)
{
grpc_pollset_destroy
(
p
);
}
...
...
@@ -83,7 +117,9 @@ int main(int argc, char **argv) {
grpc_init
();
grpc_pollset_init
(
&
g_pollset
);
test_ref_unref
();
test_add_closure
();
test_flush
();
grpc_closure_init
(
&
destroyed
,
destroy_pollset
,
&
g_pollset
);
grpc_pollset_shutdown
(
&
exec_ctx
,
&
g_pollset
,
&
destroyed
);
...
...
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