当前位置: 首页>>代码示例>>C++>>正文


C++ Timestamp::elapsed方法代码示例

本文整理汇总了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());
}
开发者ID:12307,项目名称:poco,代码行数:27,代码来源:TimerTest.cpp

示例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;
}
开发者ID:beneon,项目名称:MITK,代码行数:13,代码来源:TimedNotificationQueue.cpp

示例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());
}
开发者ID:biostone,项目名称:online,代码行数:41,代码来源:ChildSession.cpp

示例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
开发者ID:ACEZLY,项目名称:openmeeting2,代码行数:67,代码来源:MeetingConnImpl.cpp


注:本文中的Timestamp::elapsed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。