1 #ifndef BOOST_THREAD_TIME_HPP
2 #define BOOST_THREAD_TIME_HPP
3 // (C) Copyright 2007 Anthony Williams
5 // Distributed under the Boost Software License, Version 1.0. (See
6 // accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 #include <boost/date_time/time_clock.hpp>
10 #include <boost/date_time/microsec_time_clock.hpp>
11 #include <boost/date_time/posix_time/posix_time_types.hpp>
13 #include <boost/config/abi_prefix.hpp>
17 typedef boost::posix_time::ptime system_time;
19 inline system_time get_system_time()
21 #if defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
22 return boost::date_time::microsec_clock<system_time>::universal_time();
23 #else // defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
24 return boost::date_time::second_clock<system_time>::universal_time();
25 #endif // defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
30 inline system_time get_system_time_sentinel()
32 return system_time(boost::posix_time::pos_infin);
35 inline unsigned long get_milliseconds_until(system_time const& target_time)
37 if(target_time.is_pos_infinity())
39 return ~(unsigned long)0;
41 system_time const now=get_system_time();
46 return static_cast<unsigned long>((target_time-now).total_milliseconds()+1);
53 #include <boost/config/abi_suffix.hpp>