MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / doMainLoop

Function doMainLoop

source/sdl/multiThreaded/threadedMainloop.cpp:55–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53 return isMainThread;
54}
55bool doMainLoop() {
56 isMainThread = true;
57 while (platformThreadCount) {
58 U32 timeout = 5000;
59 U32 t = KSystem::getMilliesSinceStart();
60
61 if (KSystem::killTime) {
62 if (KSystem::killTime <= t) {
63 KSystem::killTime = 0;
64 KSystem::killTime2 = KSystem::getMilliesSinceStart() + 30000;
65 KNativeSystem::forceShutdown();
66 }
67 if (t - KSystem::killTime < timeout) {
68 timeout = t - KSystem::killTime;
69 }
70 }
71 if (KSystem::killTime2) {
72 if (KSystem::killTime2 <= t) {
73 klog("Forced Shutdown failed, now doing a hard exit");
74 return true;
75 }
76 if (t - KSystem::killTime2 < timeout) {
77 timeout = t - KSystem::killTime2;
78 }
79 }
80 XServer* server = XServer::getServer(true);
81 if (server) {
82 server->isDisplayDirty = true; // a bit of a hack, sometimes popups in Basstour get missed and don't draw
83 server->draw();
84 timeout = 17;
85 }
86 if (flipFB()) {
87 timeout = 17;
88 }
89#if !defined(BOXEDWINE_DISABLE_UI) && !defined(__TEST)
90 else if (uiIsRunning()) {
91 timeout = 33;
92 }
93#endif
94 U32 nextTimer = getNextTimer();
95 if (nextTimer == 0) {
96 runTimers();
97 } else if (nextTimer < timeout) {
98 timeout = nextTimer;
99 }
100 KNativeSystem::tick();
101#ifdef BOXEDWINE_RECORDER
102 if (Player::instance || Recorder::instance) {
103 KNativeSystem::getCurrentInput()->waitForEvent(10);
104 BOXEDWINE_RECORDER_RUN_SLICE();
105 } else {
106 KNativeSystem::getCurrentInput()->waitForEvent(timeout);
107 }
108#else
109 KNativeSystem::getCurrentInput()->waitForEvent(timeout);
110#endif
111#if !defined(BOXEDWINE_DISABLE_UI) && !defined(__TEST)
112 if (uiIsRunning()) {

Callers

nothing calls this directly

Calls 15

klogFunction · 0.85
flipFBFunction · 0.85
getNextTimerFunction · 0.85
runTimersFunction · 0.85
uiIsRunningFunction · 0.85
uiLoopFunction · 0.85
BFunction · 0.85
waitForEventMethod · 0.80
processEventsMethod · 0.80
getSizeFunction · 0.70
drawMethod · 0.45

Tested by

no test coverage detected