thread: Add support for posting async task
This uses the queue that was introduced when migrating impl task management from MetaThread to MetaThreadImpl, with the exception that it's now fully used as an actual queue. It now has a GSource that sits on the right GMainContext that is dispatched whenever there are tasks to execute. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
This commit is contained in:
@ -298,7 +298,8 @@ meta_thread_run_impl_task_sync (MetaThread *thread,
|
||||
MetaSyncTaskData data = { 0 };
|
||||
|
||||
task = meta_thread_task_new (func, user_data,
|
||||
sync_task_done_in_impl, &data);
|
||||
sync_task_done_in_impl, &data,
|
||||
META_THREAD_TASK_FEEDBACK_TYPE_IMPL);
|
||||
meta_thread_impl_queue_task (priv->impl, task);
|
||||
|
||||
priv->waiting_for_impl_task = TRUE;
|
||||
@ -314,6 +315,22 @@ meta_thread_run_impl_task_sync (MetaThread *thread,
|
||||
return data.retval;
|
||||
}
|
||||
|
||||
void
|
||||
meta_thread_post_impl_task (MetaThread *thread,
|
||||
MetaThreadTaskFunc func,
|
||||
gpointer user_data,
|
||||
MetaThreadTaskFeedbackFunc feedback_func,
|
||||
gpointer feedback_user_data)
|
||||
{
|
||||
MetaThreadPrivate *priv = meta_thread_get_instance_private (thread);
|
||||
MetaThreadTask *task;
|
||||
|
||||
task = meta_thread_task_new (func, user_data,
|
||||
feedback_func, feedback_user_data,
|
||||
META_THREAD_TASK_FEEDBACK_TYPE_CALLBACK);
|
||||
meta_thread_impl_queue_task (priv->impl, task);
|
||||
}
|
||||
|
||||
MetaBackend *
|
||||
meta_thread_get_backend (MetaThread *thread)
|
||||
{
|
||||
|
Reference in New Issue
Block a user