From 95b479b8c1d7c40ff97b144e3bf4349dac1b6576 Mon Sep 17 00:00:00 2001 From: Haohui Mai Date: Tue, 7 Jul 2015 13:25:51 -0700 Subject: [PATCH] HDFS-8725. Use std::chrono to implement the timer in the asio library. Contributed by Haohui Mai. --- .../src/main/native/libhdfspp/CMakeLists.txt | 2 +- .../include/asio/basic_deadline_timer.hpp | 2 ++ .../include/asio/deadline_timer.hpp | 23 +++++++++++++++++++ .../include/asio/deadline_timer_service.hpp | 2 ++ .../asio-1.10.2/include/asio/time_traits.hpp | 8 +++++++ 5 files changed, 36 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/CMakeLists.txt b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/CMakeLists.txt index 96bbaed1a3..2986b886e2 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/CMakeLists.txt +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/CMakeLists.txt @@ -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") diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/basic_deadline_timer.hpp b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/basic_deadline_timer.hpp index 6aef75cd09..d0fc371508 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/basic_deadline_timer.hpp +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/basic_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 @@ -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 diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/deadline_timer.hpp b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/deadline_timer.hpp index cf018d03b6..c0b7fe8448 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/deadline_timer.hpp +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/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 #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 + +#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 deadline_timer; +#elif defined(ASIO_CPP11_DATE_TIME) + +typedef basic_deadline_timer< + std::chrono::system_clock, + detail::chrono_time_traits>> + 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 diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/deadline_timer_service.hpp b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/deadline_timer_service.hpp index cac8ef9a7e..990c2e755f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/deadline_timer_service.hpp +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/deadline_timer_service.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 @@ -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 diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/time_traits.hpp b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/time_traits.hpp index b3a5216a4e..1a8c2df6ca 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/time_traits.hpp +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/time_traits.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 #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 struct time_traits; +#if defined(ASIO_HAS_BOOST_DATE_TIME) + /// Time traits specialised for posix_time. template <> struct time_traits @@ -78,11 +83,14 @@ struct time_traits } }; +#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