本文整理汇总了C++中boost::posix_time::time_duration::ticks_per_second方法的典型用法代码示例。如果您正苦于以下问题:C++ time_duration::ticks_per_second方法的具体用法?C++ time_duration::ticks_per_second怎么用?C++ time_duration::ticks_per_second使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::posix_time::time_duration
的用法示例。
在下文中一共展示了time_duration::ticks_per_second方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
inline struct timespec get_timespec(boost::system_time const& abs_time)
{
struct timespec timeout={0};
boost::posix_time::time_duration const time_since_epoch=abs_time-boost::posix_time::from_time_t(0);
timeout.tv_sec=time_since_epoch.total_seconds();
timeout.tv_nsec=time_since_epoch.fractional_seconds()*(1000000000/time_since_epoch.ticks_per_second());
return timeout;
}
示例2:
platform_duration(boost::posix_time::time_duration const& rel_time)
{
#if defined BOOST_THREAD_CHRONO_POSIX_API || defined BOOST_THREAD_CHRONO_MAC_API
ts_val.tv_sec = rel_time.total_seconds();
ts_val.tv_nsec = static_cast<long>(rel_time.fractional_seconds() * (1000000000l / rel_time.ticks_per_second()));
#else
ns_val = static_cast<boost::time_max_t>(rel_time.total_seconds()) * 1000000000l;
ns_val += rel_time.fractional_seconds() * (1000000000l / rel_time.ticks_per_second());
#endif
}
示例3: get_xtime
inline xtime get_xtime(boost::system_time const& abs_time)
{
xtime res={0};
boost::posix_time::time_duration const time_since_epoch=abs_time-boost::posix_time::from_time_t(0);
res.sec=static_cast<xtime::xtime_sec_t>(time_since_epoch.total_seconds());
res.nsec=static_cast<xtime::xtime_nsec_t>(time_since_epoch.fractional_seconds()*(1000000000/time_since_epoch.ticks_per_second()));
return res;
}