Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
spdlog
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
spdlog
Commits
863f704f
Commit
863f704f
authored
Aug 14, 2018
by
Luiz Siqueira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
increment counter every time we overrid a message in async mode.
parent
54896763
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
0 deletions
+22
-0
include/spdlog/details/circular_q.h
include/spdlog/details/circular_q.h
+8
-0
include/spdlog/details/mpmc_blocking_q.h
include/spdlog/details/mpmc_blocking_q.h
+5
-0
include/spdlog/details/thread_pool.h
include/spdlog/details/thread_pool.h
+5
-0
tests/test_async.cpp
tests/test_async.cpp
+4
-0
No files found.
include/spdlog/details/circular_q.h
View file @
863f704f
...
...
@@ -31,6 +31,7 @@ public:
if
(
tail_
==
head_
)
// overrun last item if full
{
head_
=
(
head_
+
1
)
%
max_items_
;
++
overrun_counter_
;
}
}
...
...
@@ -53,12 +54,19 @@ public:
return
((
tail_
+
1
)
%
max_items_
)
==
head_
;
}
int
overrun_counter
()
const
{
return
overrun_counter_
;
}
private:
size_t
max_items_
;
typename
std
::
vector
<
T
>::
size_type
head_
=
0
;
typename
std
::
vector
<
T
>::
size_type
tail_
=
0
;
std
::
vector
<
T
>
v_
;
int
overrun_counter_
=
0
;
};
}
// namespace details
}
// namespace spdlog
include/spdlog/details/mpmc_blocking_q.h
View file @
863f704f
...
...
@@ -30,6 +30,11 @@ public:
{
}
int
overrun_counter
()
const
{
return
q_
.
overrun_counter
();
}
#ifndef __MINGW32__
// try to enqueue and block if no room left
void
enqueue
(
T
&&
item
)
...
...
include/spdlog/details/thread_pool.h
View file @
863f704f
...
...
@@ -157,6 +157,11 @@ public:
post_async_msg_
(
async_msg
(
std
::
move
(
worker_ptr
),
async_msg_type
::
flush
),
overflow_policy
);
}
int
overrun_counter
()
const
{
return
q_
.
overrun_counter
();
}
private:
q_type
q_
;
...
...
tests/test_async.cpp
View file @
863f704f
...
...
@@ -7,6 +7,7 @@ TEST_CASE("basic async test ", "[async]")
{
using
namespace
spdlog
;
auto
test_sink
=
std
::
make_shared
<
sinks
::
test_sink_mt
>
();
int
overrun_counter
=
0
;
size_t
queue_size
=
128
;
size_t
messages
=
256
;
{
...
...
@@ -17,9 +18,11 @@ TEST_CASE("basic async test ", "[async]")
logger
->
info
(
"Hello message #{}"
,
i
);
}
logger
->
flush
();
overrun_counter
=
tp
->
overrun_counter
();
}
REQUIRE
(
test_sink
->
msg_counter
()
==
messages
);
REQUIRE
(
test_sink
->
flush_counter
()
==
1
);
REQUIRE
(
overrun_counter
==
0
);
}
TEST_CASE
(
"discard policy "
,
"[async]"
)
...
...
@@ -37,6 +40,7 @@ TEST_CASE("discard policy ", "[async]")
logger
->
info
(
"Hello message"
);
}
REQUIRE
(
test_sink
->
msg_counter
()
<
messages
);
REQUIRE
(
tp
->
overrun_counter
()
>
0
);
}
TEST_CASE
(
"discard policy using factory "
,
"[async]"
)
...
...
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