c++ - Difference between `deadline_timer`and `waitable_timer` in `boost asio` -
to expire timer in 5 seconds, there practical difference between these two? 1 preferable(performance, resource, etc.) other case?
[option 1] deadline_timer
:
boost::asio::deadline_timer timer(io_service); timer.expires_from_now(boost::posix_time::seconds(5));
[option 2] waitable_timer
(system_timer
or steady_timer
):
boost::asio::system_timer timer(io_service); timer.expires_from_now(std::chrono::seconds(5));
ps: please concentrate on comparing deadline_timer
vs. system_timer
, rather system_timer
vs. steady_timer
.
the difference between clock types used.
as of boost 1.56, both basic_deadline_timer
, basic_waitable_timer
utilize detail::deadline_timer_service
inside.
there's no difference in how performs waiting, difference in how performs time calculation.
in wait()
method uses time_traits::now()
check if needs wait more. system_timer
it's std::chrono::system_clock::now()
, , deadline_timer
it's boost::posix_time::microsec_clock::universal_time()
or boost::posix_time::second_clock::universal_time()
depending on presence of high precision clock (see time_traits.hpp).
std::chrono::system_clock
implementation provided compiler/standard library vendor, whereas boost::posix_time::*clock
implemented boost using available scheme functions.
these implementations of course of study may have different performance and/or precision depending on platform , compiler.
c++ boost timer boost-asio
No comments:
Post a Comment