fix doc example typo
[boost.git] / boost / thread / pthread / timespec.hpp
blobd7465c1ac35598aaeee89e207f9ef60e36fcb058
1 #ifndef BOOST_THREAD_PTHREAD_TIMESPEC_HPP
2 #define BOOST_THREAD_PTHREAD_TIMESPEC_HPP
3 // (C) Copyright 2007-8 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)
9 #include <boost/thread/thread_time.hpp>
10 #include <boost/date_time/posix_time/conversion.hpp>
11 #include <pthread.h>
12 #ifndef _WIN32
13 #include <unistd.h>
14 #endif
16 #include <boost/config/abi_prefix.hpp>
18 namespace boost
20 namespace detail
22 inline struct timespec get_timespec(boost::system_time const& abs_time)
24 struct timespec timeout={0,0};
25 boost::posix_time::time_duration const time_since_epoch=abs_time-boost::posix_time::from_time_t(0);
27 timeout.tv_sec=time_since_epoch.total_seconds();
28 timeout.tv_nsec=(long)(time_since_epoch.fractional_seconds()*(1000000000l/time_since_epoch.ticks_per_second()));
29 return timeout;
34 #include <boost/config/abi_suffix.hpp>
36 #endif