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
fe4f0012
Commit
fe4f0012
authored
8 years ago
by
Craig Tiller
Browse files
Options
Downloads
Patches
Plain Diff
Add resize test
parent
0b13fcda
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/lib/iomgr/buffer_pool.c
+34
-0
34 additions, 0 deletions
src/core/lib/iomgr/buffer_pool.c
test/core/iomgr/buffer_pool_test.c
+8
-0
8 additions, 0 deletions
test/core/iomgr/buffer_pool_test.c
with
42 additions
and
0 deletions
src/core/lib/iomgr/buffer_pool.c
+
34
−
0
View file @
fe4f0012
...
...
@@ -138,6 +138,10 @@ static void bpstep_sched(grpc_exec_ctx *exec_ctx,
/* returns true if all allocations are completed */
static
bool
bpalloc
(
grpc_exec_ctx
*
exec_ctx
,
grpc_buffer_pool
*
buffer_pool
)
{
if
(
buffer_pool
->
free_pool
<=
0
)
{
return
false
;
}
grpc_buffer_user
*
buffer_user
;
while
((
buffer_user
=
bulist_pop
(
buffer_pool
,
GRPC_BULIST_AWAITING_ALLOCATION
)))
{
...
...
@@ -242,6 +246,25 @@ static void bu_post_destructive_reclaimer(grpc_exec_ctx *exec_ctx, void *bu,
bulist_add_tail
(
buffer_user
,
GRPC_BULIST_RECLAIMER_DESTRUCTIVE
);
}
typedef
struct
{
int64_t
size
;
grpc_buffer_pool
*
buffer_pool
;
grpc_closure
closure
;
}
bp_resize_args
;
static
void
bp_resize
(
grpc_exec_ctx
*
exec_ctx
,
void
*
args
,
grpc_error
*
error
)
{
bp_resize_args
*
a
=
args
;
int64_t
delta
=
a
->
size
-
a
->
buffer_pool
->
size
;
a
->
buffer_pool
->
size
+=
delta
;
a
->
buffer_pool
->
free_pool
+=
delta
;
if
(
delta
<
0
&&
a
->
buffer_pool
->
free_pool
<
0
)
{
bpstep_sched
(
exec_ctx
,
a
->
buffer_pool
);
}
else
if
(
delta
>
0
&&
!
bulist_empty
(
a
->
buffer_pool
,
GRPC_BULIST_AWAITING_ALLOCATION
))
{
bpstep_sched
(
exec_ctx
,
a
->
buffer_pool
);
}
}
/*******************************************************************************
* grpc_buffer_pool api
*/
...
...
@@ -279,6 +302,17 @@ void grpc_buffer_pool_ref(grpc_buffer_pool *buffer_pool) {
grpc_buffer_pool_internal_ref
(
buffer_pool
);
}
void
grpc_buffer_pool_resize
(
grpc_buffer_pool
*
buffer_pool
,
size_t
size
)
{
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
bp_resize_args
*
a
=
gpr_malloc
(
sizeof
(
*
a
));
a
->
buffer_pool
=
grpc_buffer_pool_internal_ref
(
buffer_pool
);
a
->
size
=
(
int64_t
)
size
;
grpc_closure_init
(
&
a
->
closure
,
bp_resize
,
a
);
grpc_combiner_execute
(
&
exec_ctx
,
buffer_pool
->
combiner
,
&
a
->
closure
,
GRPC_ERROR_NONE
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
}
/*******************************************************************************
* grpc_buffer_user api
*/
...
...
This diff is collapsed.
Click to expand it.
test/core/iomgr/buffer_pool_test.c
+
8
−
0
View file @
fe4f0012
...
...
@@ -42,10 +42,18 @@ static void test_no_op(void) {
grpc_buffer_pool_unref
(
grpc_buffer_pool_create
());
}
static
void
test_resize_then_destroy
(
void
)
{
gpr_log
(
GPR_DEBUG
,
"** test_resize_then_destroy **"
);
grpc_buffer_pool
*
p
=
grpc_buffer_pool_create
();
grpc_buffer_pool_resize
(
p
,
1024
*
1024
);
grpc_buffer_pool_unref
(
p
);
}
int
main
(
int
argc
,
char
**
argv
)
{
grpc_test_init
(
argc
,
argv
);
grpc_init
();
test_no_op
();
test_resize_then_destroy
();
grpc_shutdown
();
return
0
;
}
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