本文整理汇总了C++中Timestamp::valid方法的典型用法代码示例。如果您正苦于以下问题:C++ Timestamp::valid方法的具体用法?C++ Timestamp::valid怎么用?C++ Timestamp::valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timestamp
的用法示例。
在下文中一共展示了Timestamp::valid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reset
void TimerQueue::reset(std::vector<TimerQueue::Entry> expired, Timestamp now)
{
for (auto iter : expired)
{
ActiveTimer timer(iter.second, iter.second->sequeue());
if (iter.second->repeat() &&
cancleTimers_.find(timer) == cancleTimers_.end())
{
iter.second->restart(now);
//timers_.insert(iter);
//activeTimers_.insert(timer);
insert(iter.second);
}
else
{
delete iter.second;
}
}
Timestamp time;
if (!timers_.empty())
{
time = timers_.begin()->second->expiration();
}
if (time.valid())
{
ext::resetTimerfd(timerfd_, time);
}
}
示例2: reset
void TimerQueue::reset(const std::vector<Entry>& expired, Timestamp now)
{
Timestamp nextExpire;
for (std::vector<Entry>::const_iterator it = expired.begin();
it != expired.end(); it++)
{
ActiveTimer timer(it->second, it->second->sequence());
if (it->second->repeat()
&& cancelingTimers_.find(timer) == cancelingTimers_.end())
{
it->second->restart(now);
insert(it->second);
}
else
{
delete it->second;
}
}
if (!timers_.empty())
{
nextExpire = timers_.begin()->second->expiration();
}
if (nextExpire.valid())
{
resetTimerfd(timerfd_, nextExpire);
}
}
示例3: loop
void EventLoop::loop()
{
assertInLoopThread();
running_ = true;
Timestamp now;
while (running_)
{
activeChannels_.clear();
int timeoutMs = 0;
now = Timestamp::now();
Timestamp nextExpired = timerQueue_->getNearestExpiration();
if(nextExpired.valid())
{
double seconds = Timestamp::timeDiff(nextExpired, now);
LOG_INFO("nextExpired.valid() [%s][%s][%lf]", nextExpired.toString().c_str(), now.toString().c_str(), seconds);
if(seconds <= 0)
timeoutMs = 0;
else
timeoutMs = seconds * 1000;
}
else
{
#if defined(POLL_WAIT_INDEFINITE)
timeoutMs = -1;
#else
timeoutMs = 0;
#endif
}
now = poller_->poll_once(timeoutMs, activeChannels_);
//LOG_INFO("EventLoop::loop [%s][%d]", now.toString().c_str(), activeChannels_.size());
eventHandling_ = true;
for (ChannelList::iterator it = activeChannels_.begin(); it != activeChannels_.end(); ++it)
{
currentActiveChannel_ = *it;
currentActiveChannel_->handleEvent(now);
}
currentActiveChannel_ = NULL;
eventHandling_ = false;
timerQueue_->runTimer(now);
callPendingFunctors(); //处理poll等待过程中发生的事件
}
}
示例4: reset
void TimerQueue::reset(const vector<Entry> &expired,
Timestamp now){
Timestamp nextExpired;
for (vector<Entry>::const_iterator it = expired.begin();
it != expired.end();
it++){
if (it->second->ifRepeat()){
it->second->restart(now);
insert(it->second);
}
else{
delete it->second;
}
}
if (!timers.empty()){
nextExpired = timers.begin()->second->getExpiration();
}
if (nextExpired.valid()){
resetTimerFd(timeFd, nextExpired);
}
}