Esempio n. 1
0
void TaskUnit::executeInBackgroundThread(TaskExecutionContext& context)
{
#ifdef LOG_TASKS
	TimedLog timedLog(mTask->getName() + ": background");
#endif

	try {
		if (mListener) {
			mListener->executionStarted();
		}
		mTask->executeTaskInBackgroundThread(context);
		if (mListener) {
			mListener->executionEnded();
		}
	} catch (const std::exception& ex) {
		if (mListener) {
			//TODO: wrap the original error somehow
			mListener->executionError(Exception("Error when executing task."));
		}
	} catch (...) {
		if (mListener) {
			mListener->executionError(Exception("Error when executing task."));
		}
	}

}
Esempio n. 2
0
void TaskUnit::executeInMainThread()
{
#ifdef LOG_TASKS
	TimedLog timedLog(mTask->getName() + ": foreground");
#endif

	//First execute all subtasks
	for (SubtasksStore::const_iterator I = mSubtasks.begin(); I != mSubtasks.end(); ++I) {
		(*I)->executeInMainThread();
	}
	mTask->executeTaskInMainThread();
}
Esempio n. 3
0
void TerrainMaterialCompilationTask::executeTaskInMainThread()
{
    TimedLog timedLog("TerrainMaterialCompilationTask::executeTaskInMainThread");
    for (CompilationInstanceStore::const_iterator J = mMaterialRecompilations.begin(); J != mMaterialRecompilations.end(); ++J) {
        TerrainPageSurfaceCompilationInstance* compilationInstance = J->first;
        TerrainPage* page = J->second;
        compilationInstance->compile(page->getMaterial());
        S_LOG_VERBOSE("Compiling terrain page composite map material");
        compilationInstance->compileCompositeMap(page->getCompositeMapMaterial());
        S_LOG_VERBOSE("Recompiled material for terrain page " << "[" << page->getWFIndex().first << "|" << page->getWFIndex().second << "]");
        page->getSurface()->getShadow()->setShadowTextureName(compilationInstance->getShadowTextureName(page->getMaterial()));
        mSignal(page); // Notify the terrain system of the material change
        delete compilationInstance;
        std::stringstream ss;
        ss << "Compiled for page [" << page->getWFIndex().first << "|" << page->getWFIndex().second << "]";
        timedLog.report(ss.str());
    }
    updateSceneManagersAfterMaterialsChange();
}
void ModelDefinitionManager::pollBackgroundLoaders(const TimeFrame& timeFrame)
{
	if (mBackgroundLoaders.size()) {
		TimedLog timedLog("ModelDefinitionManager::pollBackgroundLoaders", true);
		for (BackgroundLoaderStore::iterator I = mBackgroundLoaders.begin(); I != mBackgroundLoaders.end();)
		{
			BackgroundLoaderStore::iterator I_copy = I;
			ModelBackgroundLoader* loader(*I);
			++I;
			if (loader->poll(timeFrame)) {
				mBackgroundLoaders.erase(I_copy);
				loader->reloadModel();
				timedLog.report();
			}
			if (!timeFrame.isTimeLeft()) {
				break;
			}
		}
	}
}