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
ea611f2d
Commit
ea611f2d
authored
May 13, 2016
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reduced spinning duation in async_log_helper
parent
9b984ddb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
13 deletions
+17
-13
include/spdlog/details/async_log_helper.h
include/spdlog/details/async_log_helper.h
+17
-13
No files found.
include/spdlog/details/async_log_helper.h
View file @
ea611f2d
...
...
@@ -315,6 +315,7 @@ inline bool spdlog::details::async_log_helper::process_next_msg(log_clock::time_
}
}
// flush all sinks if _flush_interval_ms has expired
inline
void
spdlog
::
details
::
async_log_helper
::
handle_flush_interval
(
log_clock
::
time_point
&
now
,
log_clock
::
time_point
&
last_flush
)
{
auto
should_flush
=
_flush_requested
||
(
_flush_interval_ms
!=
std
::
chrono
::
milliseconds
::
zero
()
&&
now
-
last_flush
>=
_flush_interval_ms
);
...
...
@@ -326,34 +327,37 @@ inline void spdlog::details::async_log_helper::handle_flush_interval(log_clock::
_flush_requested
=
false
;
}
}
inline
void
spdlog
::
details
::
async_log_helper
::
set_formatter
(
formatter_ptr
msg_formatter
)
{
_formatter
=
msg_formatter
;
}
// s
leep,yield or return immediatly using
the time passed since last message as a hint
// s
pin, yield or sleep. use
the time passed since last message as a hint
inline
void
spdlog
::
details
::
async_log_helper
::
sleep_or_yield
(
const
spdlog
::
log_clock
::
time_point
&
now
,
const
spdlog
::
log_clock
::
time_point
&
last_op_time
)
{
using
std
::
chrono
::
milliseconds
;
using
namespace
std
::
this_thread
;
using
std
::
chrono
::
milliseconds
;
using
std
::
chrono
::
microseconds
;
auto
time_since_op
=
now
-
last_op_time
;
// spin upto
1 m
s
if
(
time_since_op
<=
mi
lliseconds
(
1
))
// spin upto
50 micro
s
if
(
time_since_op
<=
mi
croseconds
(
50
))
return
;
// yield upto 1
0m
s
if
(
time_since_op
<=
mi
lliseconds
(
1
0
))
// yield upto 1
50 micro
s
if
(
time_since_op
<=
mi
croseconds
(
10
0
))
return
yield
();
// sleep for
half of duration since last op
if
(
time_since_op
<=
milliseconds
(
1
00
))
return
sleep_for
(
time_since_op
/
2
);
// sleep for
20 ms upto 200 ms
if
(
time_since_op
<=
milliseconds
(
2
00
))
return
sleep_for
(
milliseconds
(
20
)
);
return
sleep_for
(
milliseconds
(
100
));
// sleep for 200 ms
return
sleep_for
(
milliseconds
(
200
));
}
// throw if the worker thread threw an exception or not active
...
...
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