本文整理汇总了C++中boost::posix_time::time_duration::fractional_seconds方法的典型用法代码示例。如果您正苦于以下问题:C++ time_duration::fractional_seconds方法的具体用法?C++ time_duration::fractional_seconds怎么用?C++ time_duration::fractional_seconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::posix_time::time_duration
的用法示例。
在下文中一共展示了time_duration::fractional_seconds方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: datagen_thread_loop
/* threat functions*/
void datagen_thread_loop(void)
{
ostringstream testline;
/* create testdata*/
int jj=0;
for(int ii=0; ii < 8*8-1; ii++) //64 = 63 chars + end line
{
if(++jj > 9) jj = 0;
testline << jj;
}
testline << "\n";
jj=0;
while(record_thread_running && jj < NUM_LINES)
{
#if !defined(WITH_BOOST_TIME)
clock_gettime(CLOCK_MONOTONIC, &ts_beg); // http://linux.die.net/man/3/clock_gettime
#else
start_time = boost::posix_time::microsec_clock::local_time();
#endif
// ********************************* //
*active_buffer += testline.str().c_str();
if(4*1024 < active_buffer->length()) //write 4 kbyte blocks
{
record_trigger.notify_all();
}
// ********************************* //
#if !defined(WITH_BOOST_TIME)
clock_gettime(CLOCK_MONOTONIC, &ts_end);
v_fTime_s.push_back(ts_end.tv_sec);
v_fTime_us.push_back(ts_end.tv_nsec/1e+3);
v_fDifftime.push_back((ts_end.tv_sec - ts_beg.tv_sec) + (ts_end.tv_nsec - ts_beg.tv_nsec) / 1e9);
f_DT_s = (ts_end.tv_sec - ts_beg.tv_sec) + (ts_end.tv_nsec - ts_beg.tv_nsec) / 1e9;
#else
stop_time = boost::posix_time::microsec_clock::local_time();
time_duration = (stop_time - start_time);
v_fTime_s.push_back( (stop_time-boost::posix_time::from_time_t(0)).total_seconds() );
v_fTime_us.push_back( (stop_time-boost::posix_time::from_time_t(0)).fractional_seconds() );
v_fDifftime.push_back( time_duration.total_seconds()+ time_duration.fractional_seconds()/ 1e6);
f_DT_s = (time_duration.total_seconds()+ time_duration.fractional_seconds()/ 1e6);
#endif
#if defined(DEBUG)
if(0.5 < 1.e+3*f_DT_s) // log only values above 0.5 ms
{
cout << "Line " << jj << " of " << NUM_LINES << ":"
<< "\t" << v_fTime_s.back() << "." << v_fTime_us.back() << "s: "
<< "\tdT: " << fixed << 1.e+3*f_DT_s << " ms"
<< endl;
}
#endif
boost::this_thread::sleep(boost::posix_time::microseconds(4*1e+6*f_DT_s)); //about 50% CPU load
jj++;
}//while
datagen_done = true;
}
示例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:
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;
}
示例4: 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;
}
示例5: EPOCH
value_visitor::result_type
value_visitor::operator()(const date_t& value)
{
static const date_t EPOCH(boost::gregorian::date(1970, 1, 1));
const boost::posix_time::time_duration duration = value - EPOCH;
if (duration.seconds() == 0 && duration.fractional_seconds() == 0)
{
push_back<std::int8_t>('K');
push_back<std::int32_t>(duration.total_seconds() / 60);
}
else
{
push_back<std::int8_t>('J');
push_back<std::int64_t>(duration.total_milliseconds());
}
}