static bool InitProcess() { if (s_ThreadInitialized != OS_INVALID_TLS_INDEX) return true; s_ThreadInitialized = OS_AllocTLSIndex(); if (s_ThreadInitialized == OS_INVALID_TLS_INDEX) { assert(0 && "InitProcess(): Failed to allocate TLS area for init flag"); return false; } if (!InitializePoolIndex()) { assert(0 && "InitProcess(): Failed to initalize global pool"); return false; } if (!InitializeParseContextIndex()) { assert(0 && "InitProcess(): Failed to initalize parse context"); return false; } InitThread(); return true; }
bool InitProcess() { if (ThreadInitializeIndex != OS_INVALID_TLS_INDEX) { // // Function is re-entrant. // return true; } ThreadInitializeIndex = OS_AllocTLSIndex(); if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) { assert(0 && "InitProcess(): Failed to allocate TLS area for init flag"); return false; } if (!InitializePoolIndex()) { assert(0 && "InitProcess(): Failed to initalize global pool"); return false; } if (!InitializeParseContextIndex()) { assert(0 && "InitProcess(): Failed to initalize parse context"); return false; } InitThread(); return true; }
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { switch (fdwReason) { case DLL_PROCESS_ATTACH: if (!InitProcess()) return FALSE; break; case DLL_THREAD_ATTACH: if (!InitThread()) return FALSE; break; case DLL_THREAD_DETACH: if (!DetachThread()) return FALSE; break; case DLL_PROCESS_DETACH: DetachProcess(); break; default: assert(0 && "DllMain(): Reason for calling DLL Main is unknown"); return FALSE; } return TRUE; }
int main (int argc, char * argv[]) { srand(time(NULL)); srand((unsigned int)time((time_t *)NULL)); printf("Instructions:\n" "Hold down the left mouse button to rotate image: \n" "\n" "Hold 'm' while holding down the right mouse to move the end\n" "Hold 't' while holding down the right mouse to rotate the tangent \n" "\n" "Press 'Esc' to quit\n" ); InitGLUT(argc, argv); InitLights(); InitStuff (); InitThread(argc, argv); glutMainLoop (); }
bool InitProcess() { glslang::GetGlobalLock(); if (ThreadInitializeIndex != OS_INVALID_TLS_INDEX) { // // Function is re-entrant. // glslang::ReleaseGlobalLock(); return true; } ThreadInitializeIndex = OS_AllocTLSIndex(); if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) { assert(0 && "InitProcess(): Failed to allocate TLS area for init flag"); glslang::ReleaseGlobalLock(); return false; } if (! InitializePoolIndex()) { assert(0 && "InitProcess(): Failed to initalize global pool"); glslang::ReleaseGlobalLock(); return false; } InitThread(); glslang::ReleaseGlobalLock(); return true; }
// // Do an actual link on the given compile objects. // // Return: The return value of is really boolean, indicating // success or failure. // int ShLink( const ShHandle linkHandle, const ShHandle compHandles[], const int numHandles, ShHandle uniformMapHandle, short int** uniformsAccessed, int* numUniformsAccessed) { if (!InitThread()) return 0; TShHandleBase* base = reinterpret_cast<TShHandleBase*>(linkHandle); TLinker* linker = static_cast<TLinker*>(base->getAsLinker()); if (linker == 0) return 0; int returnValue; GlobalPoolAllocator.push(); returnValue = ShLinkExt(linkHandle, compHandles, numHandles); GlobalPoolAllocator.pop(); if (returnValue) return 1; return 0; }
ShHandle C_DECL Hlsl2Glsl_ConstructCompiler( const EShLanguage language ) { if (!InitThread()) return 0; HlslCrossCompiler* compiler = new HlslCrossCompiler(language); return compiler; }
INT WINAPI DllMain( IN PVOID hInstanceDll, IN ULONG dwReason, IN PVOID reserved) { switch (dwReason) { case DLL_PROCESS_ATTACH: User32Instance = hInstanceDll; if (!RegisterClientPFN()) { return FALSE; } if (!Init()) return FALSE; if (!InitThread()) { Cleanup(); return FALSE; } /* Initialize message spying */ if (!SPY_Init()) return FALSE; break; case DLL_THREAD_ATTACH: if (!InitThread()) return FALSE; break; case DLL_THREAD_DETACH: CleanupThread(); break; case DLL_PROCESS_DETACH: if (hImmInstance) FreeLibrary(hImmInstance); CleanupThread(); Cleanup(); break; } return TRUE; }
ShHandle ShConstructCompiler(const EShLanguage language, int debugOptions) { if (!InitThread()) return 0; TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(language, debugOptions)); return reinterpret_cast<void*>(base); }
ShHandle ShConstructLinker(const EShExecutable executable, int debugOptions) { if (!InitThread()) return 0; TShHandleBase* base = static_cast<TShHandleBase*>(ConstructLinker(executable, debugOptions)); return reinterpret_cast<void*>(base); }
ShHandle ShConstructUniformMap() { if (!InitThread()) return 0; TShHandleBase* base = static_cast<TShHandleBase*>(ConstructUniformMap()); return reinterpret_cast<void*>(base); }
void CTeachingBox::Init() { InitLayout(); InitSignalSlots(); InitThread(); SlotChangeToScreenSetting(); SlotOnButtonModelClicked(); CTcpManager::GetInstance(); /*初始化net,用于在程序启动时建立连接*/ }
CProcess::CProcess(bool createThread) { terminated = false; event = NULL; // zatim nema zaznam o udalosti char x[20]; itoa((long int) this, x, 16); SetName(string("Process ")+ x); // nastavi name v CLinkage if (createThread) InitThread(); // vola CreateThread, ktera vytvori vlakno // ve stavu SUSPENDED }
const char* C_DECL Hlsl2Glsl_GetInfoLog( const ShHandle handle ) { if (!InitThread()) return 0; if (handle == 0) return 0; HlslCrossCompiler* base = static_cast<HlslCrossCompiler*>(handle); TInfoSink* infoSink = &(base->getInfoSink()); infoSink->info << infoSink->debug.c_str(); return infoSink->info.c_str(); }
int InterruptTask::Init(char *name, int priority, int intNum){ mTaskName = name; mIntNum = intNum; if(InitThread(&mIntThreadId, priority, IntThread, (void *)(this))==-1){ printf("%s:InitThread:IntThread failed\n", mTaskName); exit(1); } return 1; }
// // Turn the shader strings into a parse tree in the TIntermediate. // // Returns true for success. // bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion, EProfile defaultProfile, bool forceDefaultVersionAndProfile, bool forwardCompatible, EShMessages messages) { if (! InitThread()) return false; pool = new TPoolAllocator(); SetThreadPoolAllocator(*pool); if (! preamble) preamble = ""; return CompileDeferred(compiler, strings, numStrings, nullptr, preamble, EShOptNone, builtInResources, defaultVersion, defaultProfile, forceDefaultVersionAndProfile, forwardCompatible, messages, *intermediate); }
// // Return the index for OpenGL to use for knowing where a uniform lives. // // Return: The return value of is really boolean, indicating // success or failure. // int ShGetUniformLocation(const ShHandle handle, const char* name) { if (!InitThread()) return 0; if (handle == 0) return -1; TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle); TUniformMap* uniformMap= base->getAsUniformMap(); if (uniformMap == 0) return -1; return uniformMap->getLocation(name); }
// // Return any object code. // const char* ShGetObjectCode(const ShHandle handle) { if (!InitThread()) return 0; if (handle == 0) return 0; TShHandleBase* base = static_cast<TShHandleBase*>(handle); TInfoSink* infoSink; if (base->getAsCompiler()) infoSink = &(base->getAsCompiler()->getInfoSink()); return infoSink->obj.c_str(); }
// // Return the resulting binary code from the link process. Structure // is machine dependent. // const void* ShGetExecutable(const ShHandle handle) { if (!InitThread()) return 0; if (handle == 0) return 0; TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle); TLinker* linker = static_cast<TLinker*>(base->getAsLinker()); if (linker == 0) return 0; return linker->getObjectCode(); }
// // Let the linker know where the predefined attributes have to live. // int ShSetFixedAttributeBindings(const ShHandle handle, const ShBindingTable* table) { if (!InitThread()) return 0; if (handle == 0) return 0; TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle); TLinker* linker = static_cast<TLinker*>(base->getAsLinker()); if (linker == 0) return 0; linker->setFixedAttributeBindings(table); return 1; }
// // Return any compiler log of messages for the application. // const char* ShGetInfoLog(const ShHandle handle) { if (!InitThread()) return 0; if (handle == 0) return 0; TShHandleBase* base = static_cast<TShHandleBase*>(handle); TInfoSink* infoSink = 0; if (base->getAsCompiler()) infoSink = &(base->getAsCompiler()->getInfoSink()); infoSink->info << infoSink->debug.c_str(); return infoSink->info.c_str(); }
// // Some attribute locations are off-limits to the linker... // int ShExcludeAttributes(const ShHandle handle, int *attributes, int count) { if (!InitThread()) return 0; if (handle == 0) return 0; TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle); TLinker* linker = static_cast<TLinker*>(base->getAsLinker()); if (linker == 0) return 0; linker->setExcludedAttributes(attributes, count); return 1; }
// // Driver calls these to create and destroy compiler objects. // ShHandle ShConstructCompiler(EShLanguage language, EShSpec spec, const TBuiltInResource* resources) { if (!InitThread()) return 0; TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(language, spec)); TCompiler* compiler = base->getAsCompiler(); if (compiler == 0) return 0; // Generate built-in symbol table. if (!GenerateBuiltInSymbolTable(language, spec, *resources, compiler->getInfoSink(), compiler->getSymbolTable())) { ShDestruct(base); return 0; } return reinterpret_cast<void*>(base); }
// // Do an actual compile on the given strings. The result is left // in the given compile object. // // Return: The return value of ShCompile is really boolean, indicating // success or failure. // int ShCompile( const ShHandle handle, const char* const shaderStrings[], const int numStrings, int compileOptions) { if (!InitThread()) return 0; if (handle == 0) return 0; TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle); TCompiler* compiler = base->getAsCompiler(); if (compiler == 0) return 0; bool success = compiler->compile(shaderStrings, numStrings, compileOptions); return success ? 1 : 0; }
// // Driver calls these to create and destroy compiler objects. // ShHandle ShConstructCompiler(ShShaderType type, ShShaderSpec spec, ShShaderOutput output, const ShBuiltInResources* resources) { if (!InitThread()) return 0; TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(type, spec, output)); TCompiler* compiler = base->getAsCompiler(); if (compiler == 0) return 0; // Generate built-in symbol table. if (!compiler->Init(*resources)) { ShDestruct(base); return 0; } return reinterpret_cast<void*>(base); }
int clsThread::Run() { if (!InitThread()) return -1; _pulse pulse; for (m_nCount = 0; ; m_nCount ++) { m_bReady = TRUE; ReceivePulse(&pulse); m_bReady = FALSE; //begin working if (pulse.code == PULSECODE_EXIT) break; if (!EveryRun()) break; SetEvent(); } ExitThread(); SetEvent(); return 1; }
void IConcurrentPool::Init() { mWork = std::make_shared<boost::asio::io_service::work>( mDispatcher ); const auto f = [ = ]() { LThreadId = GetCurrentThreadId(); LThreadCallHistory = std::make_shared<ThreadCallHistory>( LThreadId ); InterlockedPushEntrySList( >hreadCallHistory, reinterpret_cast<PSLIST_ENTRY>(LThreadCallHistory.get()) ); LThreadCallElapsedRecord = std::make_shared<ThreadCallElapsedRecord>( LThreadId ); InterlockedPushEntrySList( >hreadCallElapsedRecord, reinterpret_cast<PSLIST_ENTRY>(LThreadCallElapsedRecord.get()) ); InitThread(); Run(); }; for( std::size_t i = 0; i < mPoolSize; ++i ) { mGroup.create_thread( f ); } }
int main (int argc, char * argv[]) { //srand(time(NULL)); //srand((unsigned int)time((time_t *)NULL)); printf("Instructions:\n" "Hold down the left mouse button to rotate image: \n" "\n" "Hold 'm' while holding down the right mouse to move the end\n" "Hold 't' while holding down the right mouse to rotate the tangent \n" "\n" "Press 'Esc' to quit\n" ); InitGLUT(argc, argv); InitLights(); InitStuff (); InitThread(argc, argv); signal(SIGINT, &interruptHandler); cout << "Running with CPU Threads = " << NUM_CPU_THREADS << endl; glutMainLoop (); }
CXSPThread::CXSPThread() { sem_init(&this->m_sem, 0, 0); InitThread(NULL, NULL); }
// // Do an actual compile on the given strings. The result is left // in the given compile object. // // Return: The return value of ShCompile is really boolean, indicating // success or failure. // int ShCompile( const ShHandle handle, const char* const shaderStrings[], const int numStrings, const EShOptimizationLevel optLevel, const TBuiltInResource* resources, int debugOptions ) { if (!InitThread()) return 0; if (handle == 0) return 0; TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle); TCompiler* compiler = base->getAsCompiler(); if (compiler == 0) return 0; GlobalPoolAllocator.push(); compiler->infoSink.info.erase(); compiler->infoSink.debug.erase(); if (numStrings == 0) return 1; TIntermediate intermediate(compiler->infoSink); TSymbolTable symbolTable(SymbolTables[compiler->getLanguage()]); GenerateBuiltInSymbolTable(resources, compiler->infoSink, &symbolTable, compiler->getLanguage()); TParseContext parseContext(symbolTable, intermediate, compiler->getLanguage(), compiler->infoSink); parseContext.initializeExtensionBehavior(); GlobalParseContext = &parseContext; setInitialState(); InitPreprocessor(); // // Parse the application's shaders. All the following symbol table // work will be throw-away, so push a new allocation scope that can // be thrown away, then push a scope for the current shader's globals. // bool success = true; symbolTable.push(); if (!symbolTable.atGlobalLevel()) parseContext.infoSink.info.message(EPrefixInternalError, "Wrong symbol table level"); if (parseContext.insertBuiltInArrayAtGlobalLevel()) success = false; int ret = PaParseStrings(const_cast<char**>(shaderStrings), 0, numStrings, parseContext); if (ret) success = false; if (success && parseContext.treeRoot) { if (optLevel == EShOptNoGeneration) parseContext.infoSink.info.message(EPrefixNone, "No errors. No code generation or linking was requested."); else { success = intermediate.postProcess(parseContext.treeRoot, parseContext.language); if (success) { if (debugOptions & EDebugOpIntermediate) intermediate.outputTree(parseContext.treeRoot); // // Call the machine dependent compiler // if (! compiler->compile(parseContext.treeRoot)) success = false; } } } else if (!success) { parseContext.infoSink.info.prefix(EPrefixError); parseContext.infoSink.info << parseContext.numErrors << " compilation errors. No code generated.\n\n"; success = false; if (debugOptions & EDebugOpIntermediate) intermediate.outputTree(parseContext.treeRoot); } intermediate.remove(parseContext.treeRoot); // // Ensure symbol table is returned to the built-in level, // throwing away all but the built-ins. // while (! symbolTable.atSharedBuiltInLevel()) symbolTable.pop(); FinalizePreprocessor(); // // Throw away all the temporary memory used by the compilation process. // GlobalPoolAllocator.pop(); return success ? 1 : 0; }