gwakeup: Reduce wake-ups to only first item in queue
We only need to wake up the other side of the GAsyncQueue if we transition from 0 to 1 item in the queue. Otherwise, we can be certain that the other side has received a wakeup and will eventually flush the queue. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4007>
This commit is contained in:
parent
18eb1be491
commit
1247452d19
2 changed files with 10 additions and 4 deletions
|
@ -1000,8 +1000,11 @@ _clutter_event_push (const ClutterEvent *event,
|
|||
event = copy;
|
||||
}
|
||||
|
||||
g_async_queue_push (context->events_queue, (gpointer) event);
|
||||
g_main_context_wakeup (NULL);
|
||||
g_async_queue_lock (context->events_queue);
|
||||
g_async_queue_push_unlocked (context->events_queue, (gpointer) event);
|
||||
if (g_async_queue_length_unlocked (context->events_queue) == 1)
|
||||
g_main_context_wakeup (NULL);
|
||||
g_async_queue_unlock (context->events_queue);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -599,8 +599,11 @@ meta_thread_impl_queue_task (MetaThreadImpl *thread_impl,
|
|||
MetaThreadImplPrivate *priv =
|
||||
meta_thread_impl_get_instance_private (thread_impl);
|
||||
|
||||
g_async_queue_push (priv->task_queue, task);
|
||||
g_main_context_wakeup (priv->thread_context);
|
||||
g_async_queue_lock (priv->task_queue);
|
||||
g_async_queue_push_unlocked (priv->task_queue, task);
|
||||
if (g_async_queue_length_unlocked (priv->task_queue) == 1)
|
||||
g_main_context_wakeup (priv->thread_context);
|
||||
g_async_queue_unlock (priv->task_queue);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
Loading…
Reference in a new issue