mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
thread: Add private API to flush callbacks for main context
This will be used to flush out certain callbacks when switching thread type. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
This commit is contained in:
parent
2617bd8e72
commit
84ff167328
@ -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 */
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user