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
f50020ce
Commit
f50020ce
authored
8 years ago
by
Vijay Pai
Browse files
Options
Downloads
Patches
Plain Diff
Appease the const gods, improve readability, stop using 0 and 1 as
proxies for false and true.
parent
d02988d6
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
test/cpp/qps/client.h
+4
-7
4 additions, 7 deletions
test/cpp/qps/client.h
test/cpp/qps/client_sync.cc
+2
-2
2 additions, 2 deletions
test/cpp/qps/client_sync.cc
with
6 additions
and
9 deletions
test/cpp/qps/client.h
+
4
−
7
View file @
f50020ce
...
@@ -169,7 +169,7 @@ class Client {
...
@@ -169,7 +169,7 @@ class Client {
// Must call AwaitThreadsCompletion before destructor to avoid a race
// Must call AwaitThreadsCompletion before destructor to avoid a race
// between destructor and invocation of virtual ThreadFunc
// between destructor and invocation of virtual ThreadFunc
void
AwaitThreadsCompletion
()
{
void
AwaitThreadsCompletion
()
{
gpr_atm_rel_store
(
&
thread_pool_done_
,
static_cast
<
gpr_atm
>
(
1
));
gpr_atm_rel_store
(
&
thread_pool_done_
,
static_cast
<
gpr_atm
>
(
true
));
DestroyMultithreading
();
DestroyMultithreading
();
std
::
unique_lock
<
std
::
mutex
>
g
(
thread_completion_mu_
);
std
::
unique_lock
<
std
::
mutex
>
g
(
thread_completion_mu_
);
while
(
threads_remaining_
!=
0
)
{
while
(
threads_remaining_
!=
0
)
{
...
@@ -182,7 +182,7 @@ class Client {
...
@@ -182,7 +182,7 @@ class Client {
gpr_atm
thread_pool_done_
;
gpr_atm
thread_pool_done_
;
void
StartThreads
(
size_t
num_threads
)
{
void
StartThreads
(
size_t
num_threads
)
{
gpr_atm_rel_store
(
&
thread_pool_done_
,
static_cast
<
gpr_atm
>
(
0
));
gpr_atm_rel_store
(
&
thread_pool_done_
,
static_cast
<
gpr_atm
>
(
false
));
threads_remaining_
=
num_threads
;
threads_remaining_
=
num_threads
;
for
(
size_t
i
=
0
;
i
<
num_threads
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
num_threads
;
i
++
)
{
threads_
.
emplace_back
(
new
Thread
(
this
,
i
));
threads_
.
emplace_back
(
new
Thread
(
this
,
i
));
...
@@ -274,14 +274,11 @@ class Client {
...
@@ -274,14 +274,11 @@ class Client {
if
(
entry
.
used
())
{
if
(
entry
.
used
())
{
histogram_
.
Add
(
entry
.
value
());
histogram_
.
Add
(
entry
.
value
());
}
}
bool
done
=
false
;
if
(
!
thread_still_ok
)
{
if
(
!
thread_still_ok
)
{
gpr_log
(
GPR_ERROR
,
"Finishing client thread due to RPC error"
);
gpr_log
(
GPR_ERROR
,
"Finishing client thread due to RPC error"
);
done
=
true
;
}
}
done
=
done
||
(
gpr_atm_acq_load
(
&
client_
->
thread_pool_done_
)
!=
if
(
!
thread_still_ok
||
static_cast
<
gpr_atm
>
(
0
));
static_cast
<
bool
>
(
gpr_atm_acq_load
(
&
client_
->
thread_pool_done_
)))
{
if
(
done
)
{
client_
->
CompleteThread
();
client_
->
CompleteThread
();
return
;
return
;
}
}
...
...
This diff is collapsed.
Click to expand it.
test/cpp/qps/client_sync.cc
+
2
−
2
View file @
f50020ce
...
@@ -82,12 +82,12 @@ class SynchronousClient
...
@@ -82,12 +82,12 @@ class SynchronousClient
// WaitToIssue returns false if we realize that we need to break out
// WaitToIssue returns false if we realize that we need to break out
bool
WaitToIssue
(
int
thread_idx
)
{
bool
WaitToIssue
(
int
thread_idx
)
{
if
(
!
closed_loop_
)
{
if
(
!
closed_loop_
)
{
gpr_timespec
next_issue_time
=
NextIssueTime
(
thread_idx
);
const
gpr_timespec
next_issue_time
=
NextIssueTime
(
thread_idx
);
// Avoid sleeping for too long continuously because we might
// Avoid sleeping for too long continuously because we might
// need to terminate before then. This is an issue since
// need to terminate before then. This is an issue since
// exponential distribution can occasionally produce bad outliers
// exponential distribution can occasionally produce bad outliers
while
(
true
)
{
while
(
true
)
{
gpr_timespec
one_sec_delay
=
const
gpr_timespec
one_sec_delay
=
gpr_time_add
(
gpr_now
(
GPR_CLOCK_MONOTONIC
),
gpr_time_add
(
gpr_now
(
GPR_CLOCK_MONOTONIC
),
gpr_time_from_seconds
(
1
,
GPR_TIMESPAN
));
gpr_time_from_seconds
(
1
,
GPR_TIMESPAN
));
if
(
gpr_time_cmp
(
next_issue_time
,
one_sec_delay
)
<=
0
)
{
if
(
gpr_time_cmp
(
next_issue_time
,
one_sec_delay
)
<=
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