Pumps platform-specific events on the main thread and waits for shutdown. On macOS: Runs CFRunLoop to service the main dispatch queue (required for AppKit) On other platforms: Simple blocking wait for user input
205{
206#ifdef MAYAFLUX_PLATFORM_MACOS
207 run_macos_event_loop();
208#elif defined(MAYAFLUX_PLATFORM_WINDOWS)
209 static HANDLE s_shutdown_event = CreateEventW(nullptr, TRUE, FALSE, nullptr);
210 if (!s_shutdown_event) {
212 "Failed to create shutdown event (GetLastError={}), cannot await Ctrl-C", GetLastError());
213 return;
214 }
215 ResetEvent(s_shutdown_event);
216
217 SetConsoleCtrlHandler([](DWORD
type) -> BOOL {
218 if (
type == CTRL_C_EVENT ||
type == CTRL_BREAK_EVENT ||
type == CTRL_CLOSE_EVENT) {
219 SetEvent(s_shutdown_event);
221 }
223 },
225
226 WaitForSingleObject(s_shutdown_event, INFINITE);
227#else
228 static std::atomic<bool> s_signal_received { false };
229 s_signal_received.store(false, std::memory_order_relaxed);
230
231 sigset_t block_mask, orig_mask;
232 sigemptyset(&block_mask);
233 sigaddset(&block_mask, SIGINT);
234 sigaddset(&block_mask, SIGTERM);
235 pthread_sigmask(SIG_BLOCK, &block_mask, &orig_mask);
236
237 struct sigaction sa {};
238 sigemptyset(&sa.sa_mask);
239 sa.sa_handler = [](int) { s_signal_received.store(true, std::memory_order_release); };
240 sigaction(SIGINT, &sa, nullptr);
241 sigaction(SIGTERM, &sa, nullptr);
242
243 while (!s_signal_received.load(std::memory_order_acquire)) {
244 sigsuspend(&orig_mask);
245 }
246
247 pthread_sigmask(SIG_SETMASK, &orig_mask, nullptr);
248#endif
249
251
253 "Shutdown requested, awaiting all subsystem termination ......");
254}
#define MF_LOG(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
vk::PhysicalDeviceType type
std::atomic< bool > m_should_shutdown
@ Runtime
General runtime operations (default fallback)
@ Core
Core engine, backend, subsystems.