HDFS-8725. Use std::chrono to implement the timer in the asio library. Contributed by Haohui Mai.
This commit is contained in:
parent
eb6c865516
commit
95b479b8c1
@ -18,7 +18,7 @@
|
||||
|
||||
project (libhdfspp)
|
||||
|
||||
add_definitions(-DASIO_STANDALONE)
|
||||
add_definitions(-DASIO_STANDALONE -DASIO_CPP11_DATE_TIME)
|
||||
|
||||
if(UNIX)
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -std=c++11 -g -fPIC -fno-strict-aliasing")
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "asio/detail/config.hpp"
|
||||
|
||||
#if defined(ASIO_HAS_BOOST_DATE_TIME) \
|
||||
|| defined(ASIO_CPP11_DATE_TIME) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#include <cstddef>
|
||||
@ -513,6 +514,7 @@ public:
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
// || defined(ASIO_CPP11_DATE_TIME)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#endif // ASIO_BASIC_DEADLINE_TIMER_HPP
|
||||
|
@ -18,23 +18,46 @@
|
||||
#include "asio/detail/config.hpp"
|
||||
|
||||
#if defined(ASIO_HAS_BOOST_DATE_TIME) \
|
||||
|| defined(ASIO_CPP11_DATE_TIME) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#include "asio/detail/socket_types.hpp" // Must come before posix_time.
|
||||
#include "asio/basic_deadline_timer.hpp"
|
||||
|
||||
#if defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#elif defined(ASIO_CPP11_DATE_TIME)
|
||||
|
||||
#include "asio/detail/chrono_time_traits.hpp"
|
||||
#include "asio/wait_traits.hpp"
|
||||
#include <chrono>
|
||||
|
||||
#endif
|
||||
|
||||
namespace asio {
|
||||
|
||||
#if defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
/// Typedef for the typical usage of timer. Uses a UTC clock.
|
||||
typedef basic_deadline_timer<boost::posix_time::ptime> deadline_timer;
|
||||
|
||||
#elif defined(ASIO_CPP11_DATE_TIME)
|
||||
|
||||
typedef basic_deadline_timer<
|
||||
std::chrono::system_clock,
|
||||
detail::chrono_time_traits<std::chrono::system_clock,
|
||||
wait_traits<std::chrono::system_clock>>>
|
||||
deadline_timer;
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#endif // defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
// || defined(ASIO_CPP11_DATE_TIME)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#endif // ASIO_DEADLINE_TIMER_HPP
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "asio/detail/config.hpp"
|
||||
|
||||
#if defined(ASIO_HAS_BOOST_DATE_TIME) \
|
||||
|| defined(ASIO_CPP11_DATE_TIME) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#include <cstddef>
|
||||
@ -166,6 +167,7 @@ private:
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
// || defined(ASIO_CPP11_DATE_TIME)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#endif // ASIO_DEADLINE_TIMER_SERVICE_HPP
|
||||
|
@ -18,11 +18,14 @@
|
||||
#include "asio/detail/socket_types.hpp" // Must come before posix_time.
|
||||
|
||||
#if defined(ASIO_HAS_BOOST_DATE_TIME) \
|
||||
|| defined(ASIO_CPP11_DATE_TIME) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#if defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
#include "asio/detail/push_options.hpp"
|
||||
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
#endif // defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
@ -32,6 +35,8 @@ namespace asio {
|
||||
template <typename Time>
|
||||
struct time_traits;
|
||||
|
||||
#if defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
|
||||
/// Time traits specialised for posix_time.
|
||||
template <>
|
||||
struct time_traits<boost::posix_time::ptime>
|
||||
@ -78,11 +83,14 @@ struct time_traits<boost::posix_time::ptime>
|
||||
}
|
||||
};
|
||||
|
||||
#endif // defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
|
||||
} // namespace asio
|
||||
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#endif // defined(ASIO_HAS_BOOST_DATE_TIME)
|
||||
// || defined(ASIO_CPP11_DATE_TIME)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#endif // ASIO_TIME_TRAITS_HPP
|
||||
|
Loading…
Reference in New Issue
Block a user