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


C++ Gate::open方法代码示例

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


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

示例1: processQuit

void FileStreamerThread::processQuit(volatile Request *request)
{
	NOT_NULL(request);

	ExitChain::quit();
	Gate *gate = request->gate;
	delete request;
	gate->open();
}
开发者ID:Mesagoppinmypants,项目名称:NGELinux,代码行数:9,代码来源:FileStreamerThread.cpp

示例2: processRead

void FileStreamerThread::processRead(volatile Request *request)
{
	NOT_NULL(request);

	// shortcut to the file
	OsFile *osFile = request->osFile;

	// seek to the requested offset
	osFile->seek(request->offset);

	// read the data
	if (request->bytesToBeRead > cms_maxReadSize)
	{
		// only read up to FileStreamerThread::cms_maxReadSize, then resubmit smaller request
		const int amountRead = osFile->read(request->buffer, cms_maxReadSize);

		request->offset += amountRead;
		request->bytesRead += amountRead;
		request->bytesToBeRead -= amountRead;
		request->buffer = reinterpret_cast<byte *>(request->buffer) + amountRead;

		// if we read less than we could have, we're done
		if (amountRead < cms_maxReadSize)
		{
			// store final number of bytes read in storage accessible to main thread
			*request->returnValue = static_cast<int>(request->bytesRead);

			Gate *gate = request->gate;
			delete request;

			//set event so other main thread continues
			gate->open();
		}
		else
		{
			// resubmit request (put it on the head so we get it back first)
			if (request->priority == AbstractFile::PriorityAudioVideo)
			{
				ms_queueCriticalSection.enter();
					if (ms_firstAudioVideoRequest)
					{
						request->next = ms_firstAudioVideoRequest;
						ms_firstAudioVideoRequest = request;
					}
					else
					{
						ms_firstAudioVideoRequest = request;
						ms_lastAudioVideoRequest = request;
					}
				ms_queueCriticalSection.leave();
			}
			else
				if (request->priority == AbstractFile::PriorityData)
				{
					ms_queueCriticalSection.enter();
						if (ms_firstDataRequest)
						{
							request->next = ms_firstDataRequest;
							ms_firstDataRequest = request;
						}
						else
						{
							ms_firstDataRequest = request;
							ms_lastDataRequest = request;
						}
					ms_queueCriticalSection.leave();
				}
				else
					if (request->priority == AbstractFile::PriorityLow)
					{
						ms_queueCriticalSection.enter();
							if (ms_firstLowRequest)
							{
								request->next = ms_firstLowRequest;
								ms_firstLowRequest = request;
							}
							else
							{
								ms_firstLowRequest = request;
								ms_lastLowRequest = request;
							}
						ms_queueCriticalSection.leave();
					}
					else
						DEBUG_FATAL(true, ("FileStreamerThread::processRead request has unknown priority type"));

			// signal the file thread that a new request is waiting
			ms_eventsPending.signal();
		}
	}
	else
	{
		// fulfill entire read request
		const int amountRead = osFile->read(request->buffer, request->bytesToBeRead);

		request->bytesRead += amountRead;
		request->bytesToBeRead -= amountRead;

		// store final number of bytes read in storage accessible to main thread
		*request->returnValue = static_cast<int>(request->bytesRead);
//.........这里部分代码省略.........
开发者ID:Mesagoppinmypants,项目名称:NGELinux,代码行数:101,代码来源:FileStreamerThread.cpp


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