本文整理汇总了C++中Milliseconds::totalSeconds方法的典型用法代码示例。如果您正苦于以下问题:C++ Milliseconds::totalSeconds方法的具体用法?C++ Milliseconds::totalSeconds怎么用?C++ Milliseconds::totalSeconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Milliseconds
的用法示例。
在下文中一共展示了Milliseconds::totalSeconds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
bool Timer::update(const Milliseconds& now)
{
if(_active == false)
return false;
bool hasElapsed = now >= _finished;
Timer::Sentry sentry(_sentry);
DateTime ts;
while( _active && now >= _finished )
{
Milliseconds currentTs = _finished;
// We add another interval before sending the signal
// since sending might throw an exception. We would
// skip recalculating the new time then and may loop.
_finished += _interval;
if( ! sentry )
return hasElapsed;
timeout.send();
// We send the signal with datetime only, when someone is
// connected since it will take some time to calculate a
// DateTime object from milliseconds.
if (timeoutts.connectionCount() > 0)
{
struct tm tim;
time_t sec = static_cast<time_t>(currentTs.totalSeconds());
localtime_r(&sec, &tim);
DateTime dueTime(tim.tm_year + 1900, tim.tm_mon + 1, tim.tm_mday,
tim.tm_hour, tim.tm_min, tim.tm_sec,
0, currentTs.totalUSecs() % 1000000);
timeoutts.send(dueTime);
}
if (_once)
stop();
}
return hasElapsed;
}