Chris@16: #ifndef BOOST_THREAD_TIME_HPP Chris@16: #define BOOST_THREAD_TIME_HPP Chris@16: // (C) Copyright 2007 Anthony Williams Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See Chris@16: // accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost Chris@16: { Chris@16: typedef boost::posix_time::ptime system_time; Chris@16: Chris@16: inline system_time get_system_time() Chris@16: { Chris@16: #if defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK) Chris@16: return boost::date_time::microsec_clock::universal_time(); Chris@16: #else // defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK) Chris@16: return boost::date_time::second_clock::universal_time(); Chris@16: #endif // defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK) Chris@16: } Chris@16: Chris@16: namespace detail Chris@16: { Chris@16: inline system_time get_system_time_sentinel() Chris@16: { Chris@16: return system_time(boost::posix_time::pos_infin); Chris@16: } Chris@16: Chris@16: inline unsigned long get_milliseconds_until(system_time const& target_time) Chris@16: { Chris@16: if(target_time.is_pos_infinity()) Chris@16: { Chris@16: return ~(unsigned long)0; Chris@16: } Chris@16: system_time const now=get_system_time(); Chris@16: if(target_time<=now) Chris@16: { Chris@16: return 0; Chris@16: } Chris@16: return static_cast((target_time-now).total_milliseconds()+1); Chris@16: } Chris@16: Chris@16: } Chris@16: Chris@16: } Chris@16: Chris@16: #include Chris@16: Chris@16: #endif