Acquires this and sets it as the thread-default context for the current thread.
This will cause certain asynchronous operations (such as most gio-based I/O) which are started in this thread to run under
this and deliver their results to its main loop, rather than running under the global default context in
the main thread. Note that calling this function changes the context returned by
get_thread_default, not the one returned by
@default, so it does not affect the context used by functions like
g_idle_add
.
Normally you would call this function shortly after creating a new thread, passing it a MainContext which will be run by a MainLoop in that thread, to set a new default context for all async operations in that thread. (In this case, you don't need to ever call pop_thread_default.) In some cases however, you may want to schedule a single operation in a non-default context, or temporarily use a non-default context in the main thread. In that case, you can wrap the call to the asynchronous operation inside a push_thread_default / pop_thread_default pair, but it is up to you to ensure that no other asynchronous operations accidentally get started while the non-default context is active.
Beware that libraries that predate this function may not correctly handle being used from a thread with a thread-default context. Eg, see supports_thread_contexts.
this |
a MainContext, or null for the global default context |