本文整理汇总了C++中Timestamp::elapsed方法的典型用法代码示例。如果您正苦于以下问题:C++ Timestamp::elapsed方法的具体用法?C++ Timestamp::elapsed怎么用?C++ Timestamp::elapsed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timestamp
的用法示例。
在下文中一共展示了Timestamp::elapsed方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testScheduleInterval
void TimerTest::testScheduleInterval()
{
Timer timer;
Timestamp time;
TimerTask::Ptr pTask = new TimerTaskAdapter<TimerTest>(*this, &TimerTest::onTimer);
assert (pTask->lastExecution() == 0);
timer.schedule(pTask, 500, 500);
_event.wait();
assert (time.elapsed() >= 590000);
assert (pTask->lastExecution().elapsed() < 130000);
_event.wait();
assert (time.elapsed() >= 1190000);
assert (pTask->lastExecution().elapsed() < 130000);
_event.wait();
assert (time.elapsed() >= 1790000);
assert (pTask->lastExecution().elapsed() < 130000);
pTask->cancel();
assert (pTask->isCancelled());
}
示例2: wait
bool TimedNotificationQueue::wait(Timestamp::TimeDiff interval)
{
const Timestamp::TimeDiff MAX_SLEEP = 8*60*60*Timestamp::TimeDiff(1000000); // sleep at most 8 hours at a time
while (interval > 0)
{
Timestamp now;
Timestamp::TimeDiff sleep = interval <= MAX_SLEEP ? interval : MAX_SLEEP;
if (_nfAvailable.tryWait(static_cast<long>((sleep + 999)/1000)))
return true;
interval -= now.elapsed();
}
return false;
}
示例3: sendFontRendering
void ChildSession::sendFontRendering(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
std::string font, decodedFont;
if (tokens.count() < 2 ||
!getTokenString(tokens[1], "font", font))
{
sendTextFrame("error: cmd=renderfont kind=syntax");
return;
}
std::unique_lock<std::recursive_mutex> lock(Mutex);
if (_multiView)
_loKitDocument->setView(_viewId);
URI::decode(font, decodedFont);
std::string response = "renderfont: " + Poco::cat(std::string(" "), tokens.begin() + 1, tokens.end()) + "\n";
std::vector<char> output;
output.resize(response.size());
std::memcpy(output.data(), response.data(), response.size());
Timestamp timestamp;
int width, height;
unsigned char *pixmap = _loKitDocument->renderFont(decodedFont.c_str(), &width, &height);
Log::trace("renderFont [" + font + "] rendered in " + std::to_string(timestamp.elapsed()/1000.) + "ms");
if (pixmap != nullptr)
{
if (!Util::encodeBufferToPNG(pixmap, width, height, output, LOK_TILEMODE_RGBA))
{
sendTextFrame("error: cmd=renderfont kind=failure");
delete[] pixmap;
return;
}
delete[] pixmap;
}
sendBinaryFrame(output.data(), output.size());
}
示例4: run
//.........这里部分代码省略.........
}
if(m_bStop)
{
m_bHasLogined = m_bLogicServerConnected = m_bRawSockConnected = false;
return;
}
memset(buffer,0,sizeof(buffer));
n = m_pSock->receiveBytes(buffer,sizeof(buffer));
m_lastTime = Timestamp();
if(n>0)
{
//切包,拼包
ProcessRawCommand(buffer,n);
}
else
{
if(!m_bStop)
m_pIMeetingEvent->OnNetEvent(NET_EVENT_LOST_CONNECTION,"lost connection");
goto OnError;
}
}
catch (Poco::Exception& exc)
{
std::cerr << "AA_proxy_Server: " << exc.displayText() << std::endl;
if(!m_bStop)
m_pIMeetingEvent->OnNetEvent(NET_EVENT_LOST_CONNECTION,"proxy server error");
goto OnError;
return;
}
}
//一分钟发一次心跳
if(timeHeart.elapsed()>30*1000*1000)
{
char *msg2="{\"cmd\":\"ping\"}\r\n";
if(m_bLogicServerConnected)
m_pSock->sendBytes(msg2,strlen(msg2));
timeHeart = Timestamp();
}
// 70秒没有收到数据,掉线了;
if(timeTimeout.elapsed() >30*1000*1000)
{
if(m_lastTime.elapsed()>35*1000*1000)
{
m_pIMeetingEvent->OnNetEvent(NET_EVENT_LOST_CONNECTION,"lost connection");
goto OnError;
}
timeTimeout = Timestamp();
}
if(m_bHasLogined == true && m_bLogicServerConnected == true)
{
//如果已经登录成功,检测缓冲区有没有要发送的数据,发送数据
{
FastMutex::ScopedLock autoLock(m_lock);
while(m_sendBufList.size()>0)
{
char * strSend = m_sendBufList.front();
if(m_pSock!=NULL)
{
m_pSock->sendBytes(strSend,strlen(strSend));
m_sendBufList.pop();
delete strSend;
}
else