No safe way to define custom "event" GSource without providing some kind of fd
Submitted by Sebastian Dröge
Currently it seems impossible to define a new custom GSource without having it provide a fd and having it thread-safe.
Consider a GSource that at some random point in time becomes ready to be dispatched and we know that from some thread. We now could look at the context stored in the GSource and call g_main_context_wakeup() on it, the main context would then go through prepare(), dispatch(), etc again and all would be good.
However there is nothing that allows to get the GMainContext in a threadsafe way. It might already be on the way to destruction in g_main_context_unref() when we get it from the GSource, but not set to NULL in the GSource yet.
Is there any plan, any ideas to provide some kind of thread-safe g_source_wakeup() or similar that could be used for this kind of stuff? Handling fds as an alternative would work of course, but is rather non-trivial in a platform independent way (see e.g. gwakeup.c).