MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / Sys_TriggerEvent

Function Sys_TriggerEvent

neo/sys/threads.cpp:243–261  ·  view source on GitHub ↗

================== Sys_TriggerEvent ================== */

Source from the content-addressed store, hash-verified

241==================
242*/
243void Sys_TriggerEvent(int index) {
244 assert(index >= 0 && index < MAX_TRIGGER_EVENTS);
245
246 Sys_EnterCriticalSection(CRITICAL_SECTION_SYS);
247
248 if (waiting[index]) {
249#if SDL_VERSION_ATLEAST(3, 0, 0)
250 SDL_CondSignal(cond[index]); // in SDL3, this returns void and can't fail
251#else // SDL2 and SDL1.2
252 if (SDL_CondSignal(cond[index]) != 0)
253 common->Error("ERROR: SDL_CondSignal failed\n");
254#endif
255 } else {
256 // emulate windows behaviour: if no thread is waiting, leave the signal on so next wait keeps going
257 signaled[index] = true;
258 }
259
260 Sys_LeaveCriticalSection(CRITICAL_SECTION_SYS);
261}
262
263/*
264==================

Callers 2

ShutdownMethod · 0.50
BackgroundDownloadMethod · 0.50

Calls 3

Sys_EnterCriticalSectionFunction · 0.70
Sys_LeaveCriticalSectionFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected