mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
17858cc5bd
Lets mruby-task embed cleanly in any GLib-based event loop -- GTK, libsoup, GStreamer, or anything else built on GMainContext. Tasks become regular GSources, so the scheduler runs alongside whatever else is on the loop without polling or busy-waiting. Sleeping tasks cost zero CPU: the HAL parks until the next wakeup deadline rather than ticking on a fixed cadence. Multiple mrb_states on the same thread share one dispatcher and one ticker. Preemption, Task.run, sleeper wakes, and foreign-loop integration all use the same primitives, so embedders can mix Task.run with g_main_loop_run freely. ref mruby#6825