MCPcopy Create free account
hub / github.com/ClassicOldSong/Apollo / mainThreadLoop

Function mainThreadLoop

src/main.cpp:105–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103#endif
104
105void mainThreadLoop(const std::shared_ptr<safe::event_t<bool>> &shutdown_event) {
106 bool run_loop = false;
107
108 // Conditions that would require the main thread event loop
109#ifndef _WIN32
110 run_loop = tray_is_enabled; // On Windows, tray runs in separate thread, so no main loop needed for tray
111#endif
112
113 if (!run_loop) {
114 BOOST_LOG(info) << "No main thread features enabled, skipping event loop"sv;
115 return;
116 }
117
118 // Main thread event loop
119 BOOST_LOG(info) << "Starting main loop"sv;
120 while (true) {
121 if (shutdown_event->peek()) {
122 BOOST_LOG(info) << "Shutdown event detected, breaking main loop"sv;
123 if (tray_is_enabled && config::sunshine.system_tray) {
124 system_tray::end_tray();
125 }
126 break;
127 }
128
129 if (tray_is_enabled) {
130 system_tray::process_tray_events();
131 }
132
133 // Sleep to avoid busy waiting
134 std::this_thread::sleep_for(std::chrono::milliseconds(50));
135 }
136}
137
138int main(int argc, char *argv[]) {
139 lifetime::argv = argv;

Callers 1

mainFunction · 0.85

Calls 3

end_trayFunction · 0.85
process_tray_eventsFunction · 0.85
peekMethod · 0.45

Tested by

no test coverage detected