void EarlyInit() { // If you ever want to catch a particular allocation: //_CrtSetBreakAlloc(232647); ThreadUtil::SetMainThread(); debug_SetThreadName("main"); // add all debug_printf "tags" that we are interested in: debug_filter_add("TIMER"); timer_LatchStartTime(); // initialise profiler early so it can profile startup, // but only after LatchStartTime g_Profiler2.Initialise(); FixLocales(); // Because we do GL calls from a secondary thread, Xlib needs to // be told to support multiple threads safely. // This is needed for Atlas, but we have to call it before any other // Xlib functions (e.g. the ones used when drawing the main menu // before launching Atlas) #if MUST_INIT_X11 int status = XInitThreads(); if (status == 0) debug_printf("Error enabling thread-safety via XInitThreads\n"); #endif // Initialise the low-quality rand function srand(time(NULL)); // NOTE: this rand should *not* be used for simulation! }
void* CNetServerWorker::RunThread(void* data) { debug_SetThreadName("NetServer"); static_cast<CNetServerWorker*>(data)->Run(); return NULL; }
static void* RunThread(void* data) { debug_SetThreadName("CUserReportWorker"); g_Profiler2.RegisterCurrentThread("userreport"); static_cast<CUserReporterWorker*>(data)->Run(); return NULL; }
static void* RunThread(void* data) { debug_SetThreadName("CSoundManagerWorker"); g_Profiler2.RegisterCurrentThread("soundmanager"); static_cast<CSoundManagerWorker*>(data)->Run(); return NULL; }
void* CMapGeneratorWorker::RunThread(void *data) { debug_SetThreadName("MapGenerator"); CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(data); self->m_ScriptInterface = new ScriptInterface("RMS", "MapGenerator", ScriptInterface::CreateRuntime(RMS_RUNTIME_SIZE)); // Run map generation scripts if ((!self->Run()) || (self->m_Progress > 0)) { // Don't leave progress in an unknown state, if generator failed, set it to -1 CScopeLock lock(self->m_WorkerMutex); self->m_Progress = -1; } // At this point the random map scripts are done running, so the thread has no further purpose // and can die. The data will be stored in m_MapData already if successful, or m_Progress // will contain an error value on failure. return NULL; }
static void* prof_thread_func(void* UNUSED(data)) { debug_SetThreadName("eip_sampler"); const long _1e6 = 1000000; const long _1e9 = 1000000000; for(;;) { // calculate absolute timeout for sem_timedwait struct timespec abs_timeout; clock_gettime(CLOCK_REALTIME, &abs_timeout); abs_timeout.tv_nsec += PROFILE_INTERVAL_MS * _1e6; // .. handle nanosecond wraparound (must not be > 1000m) if(abs_timeout.tv_nsec >= _1e9) { abs_timeout.tv_nsec -= _1e9; abs_timeout.tv_sec++; } errno = 0; // if we acquire the semaphore, exit was requested. if(sem_timedwait(&exit_flag, &abs_timeout) == 0) break; // actual error: warn if(errno != ETIMEDOUT) DEBUG_WARN_ERR(ERR::LOGIC); // wpcu prof_thread_func: sem_timedwait failed uintptr_t pc = get_target_pc(); UNUSED2(pc); // ADD TO LIST } return 0; }