MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ await_shutdown()

void Lila::Lila::await_shutdown ( const std::atomic< bool > *  external_flag)

Blocks until server shutdown (main thread event loop)

Parameters
external_flagstd::atomic<bool> Whether to force shutdown externally

On macOS: Runs CFRunLoop to process main queue (required for JIT GLFW) On other platforms: Simple blocking wait

Should be called on main thread after initialize() in Server mode. Returns when stop_server() is called or server fails.

Definition at line 217 of file Lila.cpp.

218{
219 LILA_INFO(Emitter::SYSTEM, "Entering main event loop");
220
221#ifdef MAYAFLUX_PLATFORM_MACOS
222 while (!m_shutdown_requested.load(std::memory_order_acquire) && (!external_flag || external_flag->load(std::memory_order_acquire))) {
223 if (!is_server_running()) {
224 LILA_ERROR(Emitter::SYSTEM, "Server stopped unexpectedly");
225 break;
226 }
227 CFRunLoopRunInMode(kCFRunLoopDefaultMode, server_loop_rate, false);
228 }
229#else
230 while (!m_shutdown_requested.load(std::memory_order_acquire) && (!external_flag || external_flag->load(std::memory_order_acquire))) {
231 if (!is_server_running()) {
232 LILA_ERROR(Emitter::SYSTEM, "Server stopped unexpectedly");
233 break;
234 }
235 std::this_thread::sleep_for(std::chrono::milliseconds(static_cast<int>(server_loop_rate * 1000)));
236 }
237#endif
238
239 LILA_INFO(Emitter::SYSTEM, "Exiting main event loop");
240}
#define LILA_ERROR(emitter, msg)
#define LILA_INFO(emitter, msg)
float server_loop_rate
Server loop rate in seconds.
Definition Lila.hpp:211
bool is_server_running() const
Checks if the server is currently running.
Definition Lila.cpp:142
std::atomic< bool > m_shutdown_requested
Definition Lila.hpp:209

References LILA_ERROR, and LILA_INFO.

Referenced by main().

+ Here is the caller graph for this function: