MayaFlux 0.4.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 228 of file Lila.cpp.

229{
230 LILA_INFO(Emitter::SYSTEM, "Entering main event loop");
231
232#ifdef MAYAFLUX_PLATFORM_MACOS
233 while (!m_shutdown_requested.load(std::memory_order_acquire) && (!external_flag || external_flag->load(std::memory_order_acquire))) {
234 if (!is_server_running()) {
235 LILA_ERROR(Emitter::SYSTEM, "Server stopped unexpectedly");
236 break;
237 }
238 CFRunLoopRunInMode(kCFRunLoopDefaultMode, server_loop_rate, false);
239 }
240
241#else
242 while (!m_shutdown_requested.load(std::memory_order_acquire) && (!external_flag || external_flag->load(std::memory_order_acquire))) {
243 if (!is_server_running()) {
244 LILA_ERROR(Emitter::SYSTEM, "Server stopped unexpectedly");
245 break;
246 }
247 std::this_thread::sleep_for(std::chrono::milliseconds(static_cast<int>(server_loop_rate * 1000)));
248 }
249#endif
250
251 LILA_INFO(Emitter::SYSTEM, "Exiting main event loop");
252}
#define LILA_ERROR(emitter, msg)
#define LILA_INFO(emitter, msg)
float server_loop_rate
Server loop rate in seconds.
Definition Lila.hpp:226
bool is_server_running() const
Checks if the server is currently running.
Definition Lila.cpp:146
std::atomic< bool > m_shutdown_requested
Definition Lila.hpp:224

References LILA_ERROR, and LILA_INFO.

Referenced by main().

+ Here is the caller graph for this function: