1#ifndef BOOST_THREAD_TIME_HPP
2#define BOOST_THREAD_TIME_HPP
3// (C) Copyright 2007 Anthony Williams
4//
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)
8
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>
12
13#include <boost/config/abi_prefix.hpp>
14
15namespace boost
16{
17 typedef boost::posix_time::ptime system_time;
18
19 inline system_time get_system_time()
20 {
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)
26 }
27
28 namespace detail
29 {
30 inline system_time get_system_time_sentinel()
31 {
32 return system_time(boost::posix_time::pos_infin);
33 }
34
35 inline unsigned long get_milliseconds_until(system_time const& target_time)
36 {
37 if(target_time.is_pos_infinity())
38 {
39 return ~(unsigned long)0;
40 }
41 system_time const now=get_system_time();
42 if(target_time<=now)
43 {
44 return 0;
45 }
46 return static_cast<unsigned long>((target_time-now).total_milliseconds()+1);
47 }
48
49 }
50
51}
52
53#include <boost/config/abi_suffix.hpp>
54
55#endif
56