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


C++ MessageQueue::PopMessage方法代码示例

本文整理汇总了C++中MessageQueue::PopMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageQueue::PopMessage方法的具体用法?C++ MessageQueue::PopMessage怎么用?C++ MessageQueue::PopMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MessageQueue的用法示例。


在下文中一共展示了MessageQueue::PopMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ErrorMessage

//blocking call
Message *MessageEndpoint::PopMessage(Ticket &ticket, int timeout)
{
	Message *ret;

	MessageQueue *queue = m_queues.GetByOurSerial(ticket.m_ourSerialNum);
	if(queue == NULL)
	{
		//Tried to read from a queue, but it didn't exist. We must have closed it, and then tried reading.
		//	This is a protocol error
		return new ErrorMessage(ERROR_PROTOCOL_MISTAKE);
	}

	//TODO: This is not quite right. We should keep returning valid messages as long as
	//	we have them. We should ask the MessageQueue for a new message (maybe peek?)
	//	and only return a shutdown message if one doesn't exist there.

	//If we're shut down, then return a shutdown message
	{
		Lock shutdownLock(&m_isShutdownMutex);
		if(m_isShutDown)
		{
			return new ErrorMessage(ERROR_SOCKET_CLOSED);
		}
	}

	ret = queue->PopMessage(timeout);

	if(ret->m_messageType == ERROR_MESSAGE)
	{
		ErrorMessage *error = (ErrorMessage*)ret;
		if(error->m_errorType == ERROR_TIMEOUT)
		{
			m_consecutiveTimeouts++;
			//TODO: deal with timeouts
		}
	}

	return ret;
}
开发者ID:ephenim,项目名称:Nova,代码行数:40,代码来源:MessageEndpoint.cpp


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