On macOS: Runs CFRunLoop to process main queue (required for JIT GLFW) On other platforms: Simple blocking wait
222{
223 LILA_INFO(Emitter::SYSTEM,
"Entering main event loop");
224
225#ifdef MAYAFLUX_PLATFORM_MACOS
226 while (!
m_shutdown_requested.load(std::memory_order_acquire) && (!external_flag || external_flag->load(std::memory_order_acquire))) {
228 LILA_ERROR(Emitter::SYSTEM,
"Server stopped unexpectedly");
229 break;
230 }
232 }
233
234#elif defined(MAYAFLUX_PLATFORM_WINDOWS)
235 if (MayaFlux::Parallel::g_MainThreadId == 0) {
236 MayaFlux::Parallel::g_MainThreadId = GetCurrentThreadId();
237 }
238
239 MSG msg;
240 PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
241
243 && (!external_flag || external_flag->load(std::memory_order_acquire))) {
245 LILA_ERROR(Emitter::SYSTEM,
"Server stopped unexpectedly");
246 break;
247 }
248
249 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
250 if (msg.message == WM_QUIT) {
252 break;
253 }
254
255 if (msg.message == MAYAFLUX_WM_DISPATCH) {
256 auto* task = reinterpret_cast<std::function<void()>*>(msg.lParam);
257 if (task) {
258 (*task)();
259 delete task;
260 }
261 } else {
262 TranslateMessage(&msg);
263 DispatchMessage(&msg);
264 }
265 }
266
267 std::this_thread::sleep_for(
269 }
270
271#else
272 while (!
m_shutdown_requested.load(std::memory_order_acquire) && (!external_flag || external_flag->load(std::memory_order_acquire))) {
274 LILA_ERROR(Emitter::SYSTEM,
"Server stopped unexpectedly");
275 break;
276 }
277 std::this_thread::sleep_for(std::chrono::milliseconds(
static_cast<int>(
server_loop_rate * 1000)));
278 }
279#endif
280
281 LILA_INFO(Emitter::SYSTEM,
"Exiting main event loop");
282}
float server_loop_rate
Server loop rate in seconds.
bool is_server_running() const
Checks if the server is currently running.
std::atomic< bool > m_shutdown_requested