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
7815d398
Commit
7815d398
authored
Jun 01, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed wait_empty() from tp and q
parent
7f6220d9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
14 deletions
+5
-14
mpmc_blocking_q.h
include/spdlog/details/mpmc_blocking_q.h
+1
-7
thread_pool.h
include/spdlog/details/thread_pool.h
+1
-5
test_async.cpp
tests/test_async.cpp
+3
-2
No files found.
include/spdlog/details/mpmc_blocking_q.h
View file @
7815d398
...
...
@@ -71,13 +71,7 @@ public:
pop_cv_
.
notify_one
();
return
true
;
}
// wait until the queue is empty
void
wait_empty
()
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
queue_mutex_
);
pop_cv_
.
wait
(
lock
,
[
this
]
{
return
this
->
q_
.
empty
();
});
}
private
:
size_t
max_items_
;
...
...
include/spdlog/details/thread_pool.h
View file @
7815d398
...
...
@@ -138,11 +138,7 @@ public:
{
return
msg_counter_
.
load
(
std
::
memory_order_relaxed
);
}
void
wait_empty
()
{
q_
.
wait_empty
();
}
private
:
std
::
atomic
<
size_t
>
msg_counter_
;
// total # of messages processed in this pool
...
...
tests/test_async.cpp
View file @
7815d398
...
...
@@ -66,7 +66,7 @@ TEST_CASE("tp->wait_empty() ", "[async]")
using
namespace
spdlog
;
auto
test_sink
=
std
::
make_shared
<
sinks
::
test_sink_mt
>
();
test_sink
->
set_delay
(
std
::
chrono
::
milliseconds
(
5
));
size_t
messages
=
5
0
;
size_t
messages
=
10
0
;
auto
tp
=
std
::
make_shared
<
details
::
thread_pool
>
(
messages
,
2
);
auto
logger
=
std
::
make_shared
<
async_logger
>
(
"as"
,
test_sink
,
tp
,
async_overflow_policy
::
block_retry
);
...
...
@@ -75,7 +75,8 @@ TEST_CASE("tp->wait_empty() ", "[async]")
logger
->
info
(
"Hello message #{}"
,
i
);
}
logger
->
flush
();
tp
->
wait_empty
();
tp
.
reset
();
REQUIRE
(
test_sink
->
msg_counter
()
==
messages
);
REQUIRE
(
test_sink
->
flush_counter
()
==
1
);
...
...
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