示例#1
0
// Runs on the main thread.
GameInfo *GameInfoCache::GetInfo(Thin3DContext *thin3d, const std::string &gamePath, int wantFlags) {
	GameInfo *info = 0;

	auto iter = info_.find(gamePath);
	if (iter != info_.end()) {
		info = iter->second;
		if ((info->wantFlags & wantFlags) != wantFlags) {
			// Need to start over. We'll just add a new work item.
			goto again;
		}
		if (thin3d && info->iconDataLoaded) {
			SetupTexture(info, info->iconTextureData, thin3d, info->iconTexture, info->timeIconWasLoaded);
			info->iconDataLoaded = false;
		}
		if (thin3d && info->pic0DataLoaded) {
			SetupTexture(info, info->pic0TextureData, thin3d, info->pic0Texture, info->timePic0WasLoaded);
			info->pic0DataLoaded = false;
		}
		if (thin3d && info->pic1DataLoaded) {
			SetupTexture(info, info->pic1TextureData, thin3d, info->pic1Texture, info->timePic1WasLoaded);
			info->pic1DataLoaded = false;
		}
		iter->second->lastAccessedTime = time_now_d();
		return iter->second;
	}

again:

	if (!info) {
		info = new GameInfo();
	}

	{
		lock_guard lock(info->lock);
		if (info->IsWorking()) {
			// Uh oh, it's currently in process.  It could mark pending = false with the wrong wantFlags.
			// Let's wait it out, then queue.
			WaitUntilDone(info);
		}
		info->wantFlags |= wantFlags;
		info->pending = true;
	}

	GameInfoWorkItem *item = new GameInfoWorkItem(gamePath, info);
	gameInfoWQ_->Add(item);

	info_[gamePath] = info;
	return info;
}
示例#2
0
bool GPxiBasicAnalogOutput::UpdatePhysicalOutput( double newSetPoint )
{
	try {
		// Create a writer
		CNiDAQmxAnalogSingleChannelWriter m_writer(Stream);
		// And write immediately
		m_writer.WriteSingleSample(true, newSetPoint);
		// Wait until the I/O completes before destroying the task
		WaitUntilDone(-1);
	}
	catch (CNiDAQmxException *exception) {
		exception->ReportError();
		exception->Delete();
		return false;
	}
	return true;
}