diff --git a/include/boost/thread/detail/thread.hpp b/include/boost/thread/detail/thread.hpp index 53a1a3de..ca79c3bf 100644 --- a/include/boost/thread/detail/thread.hpp +++ b/include/boost/thread/detail/thread.hpp @@ -506,10 +506,20 @@ namespace boost bool do_try_join_for_noexcept(uintmax_t milli, bool& res); inline bool do_try_join_for(uintmax_t milli); public: - bool timed_join(const system_time& abs_time); - //{ - // return do_try_join_for(get_milliseconds_until(wait_until)); - //} +#if defined BOOST_THREAD_USES_DATETIME + bool timed_join(const system_time& abs_time) + { + posix_time::time_duration d = abs_time - get_system_time(); + d = (std::min)(d, posix_time::time_duration(posix_time::milliseconds(100))); + while ( ! do_try_join_for(d.total_milliseconds()) ) + { + d = abs_time - get_system_time(); + if ( d <= posix_time::milliseconds(0) ) return false; + d = (std::min)(d, posix_time::time_duration(posix_time::milliseconds(100))); + } + return true; + } +#endif #ifdef BOOST_THREAD_USES_CHRONO template diff --git a/src/win32/thread.cpp b/src/win32/thread.cpp index 9e8d7991..bccdaa10 100644 --- a/src/win32/thread.cpp +++ b/src/win32/thread.cpp @@ -459,12 +459,6 @@ namespace boost } } -#if defined BOOST_THREAD_USES_DATETIME - bool thread::timed_join(boost::system_time const& wait_until) - { - return do_try_join_for(boost::detail::get_milliseconds_until(wait_until)); - } -#endif bool thread::do_try_join_for_noexcept(uintmax_t milli, bool& res) { detail::thread_data_ptr local_thread_info=(get_thread_info)();