Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
spdlog
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
spdlog
Commits
b002a21c
Commit
b002a21c
authored
May 26, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use underscore at end of private members names
parent
7a339e2b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
thread_pool.h
include/spdlog/details/thread_pool.h
+9
-9
No files found.
include/spdlog/details/thread_pool.h
View file @
b002a21c
...
...
@@ -89,7 +89,7 @@ public:
thread_pool
(
size_t
q_size_bytes
,
size_t
threads_n
)
:
msg_counter_
(
0
)
,
_q
(
q_size_bytes
)
,
q_
(
q_size_bytes
)
{
// std::cout << "thread_pool() q_size_bytes: " << q_size_bytes << "\tthreads_n: " << threads_n << std::endl;
if
(
threads_n
==
0
||
threads_n
>
1000
)
...
...
@@ -98,7 +98,7 @@ public:
}
for
(
size_t
i
=
0
;
i
<
threads_n
;
i
++
)
{
_threads
.
emplace_back
(
std
::
bind
(
&
thread_pool
::
worker_loop
,
this
));
threads_
.
emplace_back
(
std
::
bind
(
&
thread_pool
::
worker_loop
,
this
));
}
}
...
...
@@ -107,12 +107,12 @@ public:
{
try
{
for
(
size_t
i
=
0
;
i
<
_threads
.
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
threads_
.
size
();
i
++
)
{
post_async_msg
(
async_msg
(
async_msg_type
::
terminate
),
async_overflow_policy
::
block_retry
);
}
for
(
auto
&
t
:
_threads
)
for
(
auto
&
t
:
threads_
)
{
t
.
join
();
}
...
...
@@ -141,19 +141,19 @@ public:
private
:
std
::
atomic
<
size_t
>
msg_counter_
;
// total # of messages processed in this pool
q_type
_q
;
q_type
q_
;
std
::
vector
<
std
::
thread
>
_threads
;
std
::
vector
<
std
::
thread
>
threads_
;
void
post_async_msg
(
async_msg
&&
new_msg
,
async_overflow_policy
overflow_policy
)
{
if
(
overflow_policy
==
async_overflow_policy
::
block_retry
)
{
_q
.
enqueue
(
std
::
move
(
new_msg
));
q_
.
enqueue
(
std
::
move
(
new_msg
));
}
else
{
_q
.
enqueue_nowait
(
std
::
move
(
new_msg
));
q_
.
enqueue_nowait
(
std
::
move
(
new_msg
));
}
}
...
...
@@ -167,7 +167,7 @@ private:
bool
process_next_msg
()
{
async_msg
incoming_async_msg
;
bool
dequeued
=
_q
.
dequeue_for
(
incoming_async_msg
,
std
::
chrono
::
seconds
(
10
));
bool
dequeued
=
q_
.
dequeue_for
(
incoming_async_msg
,
std
::
chrono
::
seconds
(
10
));
if
(
!
dequeued
)
{
return
true
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment