本文整理汇总了C++中poco::Timestamp::isElapsed方法的典型用法代码示例。如果您正苦于以下问题:C++ Timestamp::isElapsed方法的具体用法?C++ Timestamp::isElapsed怎么用?C++ Timestamp::isElapsed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类poco::Timestamp
的用法示例。
在下文中一共展示了Timestamp::isElapsed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Debounce
bool Debounce(void) {
if (fpsTimeLast.isElapsed(debounceTimeout.totalMicroseconds())) {
fpsTimeLast.update();
return true;
} else {
return false;
}
}
示例2: receiveFrom
int ICMPSocketImpl::receiveFrom(void*, int, SocketAddress& address, int flags)
{
int maxPacketSize = _icmpPacket.maxPacketSize();
unsigned char* buffer = new unsigned char[maxPacketSize];
try
{
Poco::Timestamp ts;
do
{
if (ts.isElapsed(_timeout))
{
// This guards against a possible DoS attack, where sending
// fake ping responses will cause an endless loop.
throw TimeoutException();
}
SocketImpl::receiveFrom(buffer, maxPacketSize, address, flags);
}
while (!_icmpPacket.validReplyID(buffer, maxPacketSize));
}
catch (TimeoutException&)
{
delete [] buffer;
throw;
}
catch (Exception&)
{
std::string err = _icmpPacket.errorDescription(buffer, maxPacketSize);
delete [] buffer;
if (!err.empty())
throw ICMPException(err);
else
throw;
}
struct timeval then = _icmpPacket.time(buffer, maxPacketSize);
struct timeval now = _icmpPacket.time();
int elapsed = (((now.tv_sec * 1000000) + now.tv_usec) - ((then.tv_sec * 1000000) + then.tv_usec))/1000;
delete[] buffer;
return elapsed;
}
示例3: run
void run()
{
Poco::Timestamp lastScan;
ItemInfoMap entries;
scan(entries);
while (!_stopped)
{
struct timespec timeout;
timeout.tv_sec = 0;
timeout.tv_nsec = 200000000;
unsigned eventFilter = NOTE_WRITE;
struct kevent event;
struct kevent eventData;
EV_SET(&event, _dirFD, EVFILT_VNODE, EV_ADD | EV_CLEAR, eventFilter, 0, 0);
int nEvents = kevent(_queueFD, &event, 1, &eventData, 1, &timeout);
if (nEvents < 0 || eventData.flags == EV_ERROR)
{
try
{
FileImpl::handleLastErrorImpl(owner().directory().path());
}
catch (Poco::Exception& exc)
{
owner().scanError(&owner(), exc);
}
}
else if (nEvents > 0 || ((owner().eventMask() & DirectoryWatcher::DW_ITEM_MODIFIED) && lastScan.isElapsed(owner().scanInterval()*1000000)))
{
ItemInfoMap newEntries;
scan(newEntries);
compare(entries, newEntries);
std::swap(entries, newEntries);
lastScan.update();
}
}
}