diff --git a/src/backends/native/meta-thread-private.h b/src/backends/native/meta-thread-private.h index 56f6e45c6..4b120c928 100644 --- a/src/backends/native/meta-thread-private.h +++ b/src/backends/native/meta-thread-private.h @@ -33,4 +33,7 @@ MetaThreadType meta_thread_get_thread_type (MetaThread *thread); GThread * meta_thread_get_thread (MetaThread *thread); +void meta_thread_dispatch_callbacks (MetaThread *thread, + GMainContext *main_context); + #endif /* META_THREAD_PRIVATE_H */ diff --git a/src/backends/native/meta-thread.c b/src/backends/native/meta-thread.c index d1a1f9e95..80b6beeef 100644 --- a/src/backends/native/meta-thread.c +++ b/src/backends/native/meta-thread.c @@ -704,6 +704,28 @@ dispatch_callbacks (MetaThread *thread, return callback_count; } +void +meta_thread_dispatch_callbacks (MetaThread *thread, + GMainContext *main_context) +{ + MetaThreadPrivate *priv = meta_thread_get_instance_private (thread); + MetaThreadCallbackSource *callback_source; + g_autoptr (GList) pending_callbacks = NULL; + + if (!main_context) + main_context = g_main_context_default (); + + callback_source = g_hash_table_lookup (priv->callback_sources, main_context); + + g_assert (callback_source->main_context == main_context); + + g_mutex_lock (&priv->callbacks_mutex); + pending_callbacks = g_steal_pointer (&callback_source->callbacks); + g_mutex_unlock (&priv->callbacks_mutex); + + dispatch_callbacks (thread, pending_callbacks); +} + void meta_thread_flush_callbacks (MetaThread *thread) {