static void initialize() { lcpp::startup(); g_pEzEngineLogger = EZ_NEW(lcpp::defaultAllocator(), cut::loggers::ezEngineWriter)(cut::ILogManager::instance(), ezLog::GetDefaultLogSystem()); g_pHtmlLog = EZ_NEW(lcpp::defaultAllocator(), ezLogWriter::HTML)(); ezFileSystem::RegisterDataDirectoryFactory(ezDataDirectory::FolderType::Factory); ezGlobalLog::AddLogWriter(ezLogWriter::Console::LogMessageHandler); ezGlobalLog::AddLogWriter(ezLogWriter::VisualStudio::LogMessageHandler); ezGlobalLog::SetLogLevel(ezLogMsgType::All); ezStringBuilder testDir; lcpp::getCurrentWorkingDirectory(testDir); ezStringBuilder logFile; logFile.AppendPath("temp", "log"); logFile.MakeAbsolutePath(testDir.GetData()); logFile.MakeCleanPath(); ezOSFile::CreateDirectoryStructure(logFile.GetData()); if (ezFileSystem::AddDataDirectory(logFile.GetData(), ezFileSystem::AllowWrites, "log-dir").Failed()) { return; } ezGlobalLog::AddLogWriter(ezLoggingEvent::Handler(&ezLogWriter::HTML::LogMessageHandler, g_pHtmlLog)); logFile.AppendPath("lcppCoreCont_unittests.log.html"); g_pHtmlLog->BeginLog(logFile.GetFileNameAndExtension().GetData(), logFile.GetFileNameAndExtension().GetData()); testDir.AppendPath("data1", "test"); testDir.MakeCleanPath(); auto addingDataDirectory = ezFileSystem::AddDataDirectory(testDir.GetData(), ezFileSystem::ReadOnly, "test-data"); if(addingDataDirectory.Failed()) { testDir.Prepend("Failed to add test data directory: "); throw std::exception(testDir.GetData()); } LCPP_test_pRuntimeState->setUserDirectory(testDir.GetData()); }
void lcpp::LispRuntimeState::initialize(ezAllocatorBase* pAllocator) { EZ_ASSERT(m_stats.m_shutdownCount <= m_stats.m_initializationCount, "LCPP_pRuntime was shut down more often than it was initialized!"); if (m_stats.m_shutdownCount < m_stats.m_initializationCount) { shutdown(); } EZ_ASSERT(m_stats.m_initializationCount == m_stats.m_shutdownCount, "LCPP_pRuntime initialization and shutdown count must be balanced!"); ++m_stats.m_initializationCount; m_pAllocator = pAllocator ? pAllocator : defaultAllocator(); m_pGC = lcpp::getGarbageCollector(); #if EZ_ENABLED(EZ_COMPILE_FOR_DEBUG) g_pGC = m_pGC.get(); #endif m_pSyntaxEnvironment = env::createTopLevel(symbol::create("syntax")).get(); m_pGC->addRoot(m_pSyntaxEnvironment); m_pGlobalEnvironment = env::create(getSyntaxEnvironment(), symbol::create("global")).get(); m_pGC->addRoot(m_pGlobalEnvironment); ////////////////////////////////////////////////////////////////////////// m_pReaderState = EZ_NEW(defaultAllocator(), reader::State); m_pReaderState->m_pMacroEnv = env::createTopLevel(symbol::create("reader-macros")); m_pGC->addRoot(m_pReaderState->m_pMacroEnv.get()); m_pPrinterState = EZ_NEW(defaultAllocator(), printer::State); ////////////////////////////////////////////////////////////////////////// registerBuiltIns(); }
void ezWorld::UpdateAsynchronous() { ezTaskGroupID taskGroupId = ezTaskSystem::CreateTaskGroup(ezTaskPriority::EarlyThisFrame); ezDynamicArrayBase<ezInternal::WorldData::RegisteredUpdateFunction>& updateFunctions = m_Data.m_UpdateFunctions[ezComponentManagerBase::UpdateFunctionDesc::Phase::Async]; ezUInt32 uiCurrentTaskIndex = 0; for (auto& updateFunction : updateFunctions) { if (updateFunction.m_bOnlyUpdateWhenSimulating && !m_Data.m_bSimulateWorld) continue; ezComponentManagerBase* pManager = static_cast<ezComponentManagerBase*>(updateFunction.m_Function.GetClassInstance()); const ezUInt32 uiTotalCount = pManager->GetComponentCount(); ezUInt32 uiStartIndex = 0; ezUInt32 uiGranularity = (updateFunction.m_uiGranularity != 0) ? updateFunction.m_uiGranularity : uiTotalCount; while (uiStartIndex < uiTotalCount) { ezInternal::WorldData::UpdateTask* pTask; if (uiCurrentTaskIndex < m_Data.m_UpdateTasks.GetCount()) { pTask = m_Data.m_UpdateTasks[uiCurrentTaskIndex]; } else { pTask = EZ_NEW(&m_Data.m_Allocator, ezInternal::WorldData::UpdateTask); m_Data.m_UpdateTasks.PushBack(pTask); } pTask->SetTaskName(updateFunction.m_sFunctionName); pTask->m_Function = updateFunction.m_Function; pTask->m_uiStartIndex = uiStartIndex; pTask->m_uiCount = (uiStartIndex + uiGranularity < uiTotalCount) ? uiGranularity : ezInvalidIndex; ezTaskSystem::AddTaskToGroup(taskGroupId, pTask); ++uiCurrentTaskIndex; uiStartIndex += uiGranularity; } } ezTaskSystem::StartTaskGroup(taskGroupId); ezTaskSystem::WaitForGroup(taskGroupId); }