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
59013b35
Commit
59013b35
authored
Nov 16, 2014
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
async_sink to use queue of pointers of log_msgs - faster than moving..
parent
a9abfbb0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
async_sink.h
include/spdlog/sinks/async_sink.h
+14
-5
No files found.
include/spdlog/sinks/async_sink.h
View file @
59013b35
...
...
@@ -53,7 +53,7 @@ namespace sinks
class
async_sink
:
public
base_sink
<
details
::
null_mutex
>
{
public
:
using
q_type
=
details
::
blocking_queue
<
details
::
log_msg
>
;
using
q_type
=
details
::
blocking_queue
<
std
::
unique_ptr
<
details
::
log_msg
>
>
;
explicit
async_sink
(
const
q_type
::
size_type
max_queue_size
);
...
...
@@ -64,14 +64,18 @@ public:
q_type
&
q
();
//Wait to remaining items (if any) in the queue to be written and shutdown
void
shutdown
(
const
std
::
chrono
::
milliseconds
&
timeout
);
void
set_formatter
(
formatter_ptr
formatter
)
{
_formatter
=
formatter
;
}
protected
:
void
_sink_it
(
const
details
::
log_msg
&
msg
)
override
;
void
_thread_loop
();
private
:
void
_thread_loop
();
std
::
vector
<
std
::
shared_ptr
<
sink
>>
_sinks
;
std
::
atomic
<
bool
>
_active
;
q_type
_q
;
...
...
@@ -80,7 +84,8 @@ private:
//Last exception thrown from the back thread
std
::
shared_ptr
<
spdlog_ex
>
_last_backthread_ex
;
//formatter
formatter_ptr
_formatter
;
//will throw last back thread exception or if backthread no active
void
_push_sentry
();
...
...
@@ -108,8 +113,11 @@ inline spdlog::sinks::async_sink::~async_sink()
inline
void
spdlog
::
sinks
::
async_sink
::
_sink_it
(
const
details
::
log_msg
&
msg
)
{
using
namespace
spdlog
::
details
;
_push_sentry
();
_q
.
push
(
msg
);
//_q.push(std::move(msg));
auto
msg_p
=
std
::
unique_ptr
<
log_msg
>
(
new
log_msg
(
msg
));
_q
.
push
(
std
::
move
(
msg_p
));
}
...
...
@@ -124,11 +132,12 @@ inline void spdlog::sinks::async_sink::_thread_loop()
{
if
(
!
_active
)
return
;
_formatter
->
format
(
*
msg
);
for
(
auto
&
s
:
_sinks
)
{
try
{
s
->
log
(
msg
);
s
->
log
(
*
msg
);
}
catch
(
const
std
::
exception
&
ex
)
...
...
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