void GetServerPingsAndInfos(int full) { if (serverinfo_lock || SB_PingTree_IsBuilding()) { Com_Printf("Server list refresh is still pending\n"); return; } serverinfo_lock = 1; if (rebuild_servers_list) Rebuild_Servers_List(); if (rebuild_all_players && show_serverinfo == NULL) Rebuild_All_Players(); if (serversn <= 0 || (sb_hidedead.integer == 0 && SB_AllServersDead())) { // there's a possibility that sources hasn't been queried yet // so let's do a full update, that ensures sources are updated full = true; } ping_phase = 1; ping_pos = 0; Sys_CreateThread (GetServerPingsAndInfosProc, (void *) full); }
void CAccepter::beginAcceptLounge(SOCKET sockfd, struct sockaddr_in* addr) { if (numThreads_ < maxThreads_) { AcceptItem* pI = new AcceptItem(sockfd, *addr); if (pI) { if (Sys_CreateThread(AcceptLoungeProc, (void*)pI) == -1) { Err::Log() << "Could not create accept thread.\n"; ::closesocket(sockfd); } } else { Err::Log() << "CAccepter out of memory.\n"; ::closesocket(sockfd); } } else { Err::Log() << "Too many accept threads.\n"; ::closesocket(sockfd); } }
static qboolean QDECL WASAPI_InitCard (soundcardinfo_t *sc, const char *cardname) { void *cond; if (cardname && *cardname) return false; //we don't support explicit devices at this time Q_strncpyz(sc->name, cardname?cardname:"", sizeof(sc->name)); sc->selfpainting = true; sc->handle = cond = Sys_CreateConditional(); Sys_LockConditional(cond); sc->thread = Sys_CreateThread("wasapimixer", WASAPI_Thread, sc, THREADP_NORMAL, 0); if (!sc->thread) { Con_Printf ("Unable to create sound mixing thread\n"); return false; } // MessageBox(0,"main thread waiting", "...", 0); //wait for the thread to finish (along with all its error con printfs etc if (!Sys_ConditionWait(cond)) Con_Printf ("Looks like the sound thread isn't starting up\n"); Sys_UnlockConditional(cond); Sys_DestroyConditional(cond); COM_MainThreadWork(); //flush any prints from the worker thread, so that things make sense if (sc->Shutdown == NULL) { Sys_WaitOnThread(sc->thread); sc->thread = NULL; return false; } return true; }
/* ================= Posix_StartAsyncThread ================= */ void Posix_StartAsyncThread() { if ( asyncThread.threadHandle == 0 ) { Sys_CreateThread( (xthread_t)Sys_AsyncThread, NULL, THREAD_NORMAL, asyncThread, "Async", g_threads, &g_thread_count ); } else { common->Printf( "Async thread already running\n" ); } common->Printf( "Async thread started\n" ); }
static void SB_PingTree_ScanProxies(void) { int i; proxy_request_queue queue = { NULL, 0, false }; size_t request = 0; FILE *f = NULL; for (i = 0; i < ping_nodes_count; i++) { if (ping_nodes[i].proxport) { queue.items++; } } if (!queue.items) return; queue.data = (proxy_query_request_t *) Q_malloc(sizeof(proxy_query_request_t) * queue.items); for (i = 0; i < ping_nodes_count; i++) { if (ping_nodes[i].proxport) { queue.data[request].done = false; queue.data[request].nodeid = i; queue.data[request].sock = UDP_OpenSocket(NA_IPv4, PORT_ANY); request++; } } if (sb_listcache.value) { f = fopen(va("%s/%s", com_homedir, "proxies_data"), "wb"); if (f) SB_Proxylist_Serialize_Start(f); } for (i = 0; i < sb_proxretries.integer; i++) { queue.sending_done = false; Sys_CreateThread(SB_PingTree_SendQueryThread, (void *) &queue); SB_PingTree_RecvQuery(&queue, f); if (queue.allrecved) { break; } } if (f) { SB_Proxylist_Serialize_End(f); fclose(f); } while (!queue.sending_done) { // XXX: use semaphore instead Sys_MSleep(100); } for (i = 0; i < queue.items; i++) { closesocket(queue.data[i].sock); } Q_free(queue.data); }
void QTVList_Initialize_Streammap(void) { if (sb_qtvlist_cache.status != QTVLIST_READY && sb_qtvlist_cache.status != QTVLIST_INIT) { Com_Printf("QTV cache is still being rebuilt\n"); return; } sb_qtvlist_cache.status = QTVLIST_PROCESSING; Sys_CreateThread(QTVList_Refresh_Cache_Thread, (void *) false); }
void QTVList_Print_Global(void) { if (sb_qtvlist_cache.status != QTVLIST_READY && sb_qtvlist_cache.status != QTVLIST_INIT) { Com_Printf("QTV cache is still being rebuilt\n"); return; } sb_qtvlist_cache.status = QTVLIST_PROCESSING; Sys_CreateThread(QTVList_Download_And_Print_Thread, NULL); }
void Log_AutoLogging_Upload(const char *filename) { log_upload_job_t *job = Log_Upload_Job_Prepare(filename, Info_ValueForKey(cl.serverinfo, "hostname"), cl.players[cl.playernum].name, match_auto_logupload_token.string, match_auto_logurl.string, host_mapname.string); Com_Printf("Uploading match log...\n"); Sys_CreateThread(Log_AutoLogging_Upload_Thread, (void *) job); }
void Deferred_Send(const serverinfo *svinfo, const char *ip, short port, playerscore *scores, bool teamplay) { DeferredSendData *data = new DeferredSendData; data->ip = ip; data->port = port; data->svinfo = svinfo; data->scores = scores; data->teamplay = teamplay; Sys_CreateThread(DeferredSendThread, (void *) data); }
/// Creates whole graph structure for looking up shortest paths to servers (ping-wise). /// /// Grabs data from the server browser and then from the proxies. void SB_PingTree_Build(void) { if (building_pingtree) { Com_Printf("Ping Tree is still being built...\n"); return; } // no race condition here, as this must always get executed by the main thread building_pingtree = true; Com_Printf("Building the Ping Tree...\n"); // first quick phase is initialization + quick read of data from the server browser SB_PingTree_Phase1(); // second longer phase is querying the proxies for their ping data + dijkstra algo Sys_SemWait(&phase2thread_lock); Sys_CreateThread(SB_PingTree_Phase2, NULL); }
/* ======================== idJoystickWin32::Init ======================== */ bool idJoystickWin32::Init() { idJoystick::Init(); // setup the timer that the high frequency thread will wait on // to fire every 4 msec timer = CreateWaitableTimer( NULL, FALSE, "JoypadTimer" ); LARGE_INTEGER dueTime; dueTime.QuadPart = -1; if( !SetWaitableTimer( timer, &dueTime, 4, NULL, NULL, FALSE ) ) { idLib::FatalError( "SetWaitableTimer for joystick failed" ); } // spawn the high frequency joystick reading thread Sys_CreateThread( ( xthread_t )JoystickSamplingThread, NULL, THREAD_HIGHEST, "Joystick", CORE_1A ); return false; }
/* ======================== idSysThread::StartThread ======================== */ bool idSysThread::StartThread( const char* name_, core_t core, xthreadPriority priority, int stackSize ) { if( isRunning ) { return false; } name = name_; isTerminating = false; if( threadHandle ) { Sys_DestroyThread( threadHandle ); } threadHandle = Sys_CreateThread( ( xthread_t )ThreadProc, this, priority, name, core, stackSize, false ); isRunning = true; return true; }
/* ============== Sys_StartAsyncThread Start the thread that will call idCommon::Async() ============== */ void Sys_StartAsyncThread( void ) { // create an auto-reset event that happens 60 times a second hTimer = CreateWaitableTimer( NULL, false, NULL ); if ( !hTimer ) { common->Error( "idPacketServer::Spawn: CreateWaitableTimer failed" ); } LARGE_INTEGER t; t.HighPart = t.LowPart = 0; SetWaitableTimer( hTimer, &t, USERCMD_MSEC, NULL, NULL, TRUE ); Sys_CreateThread( (xthread_t)Sys_AsyncThread, NULL, THREAD_ABOVE_NORMAL, threadInfo, "Async", g_threads, &g_thread_count ); #ifdef SET_THREAD_AFFINITY // give the async thread an affinity for the second cpu SetThreadAffinityMask( (HANDLE)threadInfo.threadHandle, 2 ); #endif if ( !threadInfo.threadHandle ) { common->Error( "Sys_StartAsyncThread: failed" ); } }
void Start_Autoupdate(server_data *s) { autoupdate_server = s; Sys_CreateThread(AutoupdateProc, (void *) s); }
// starts asynchronous sources update void Update_Multiple_Sources_Begin(source_data *s[], int sn) { Update_Init(s, sn); Sys_CreateThread(Update_Multiple_Sources_Proc, NULL); }