diff --git a/clutter/clutter/clutter-event.c b/clutter/clutter/clutter-event.c index bcda1bb7b..8c17cee38 100644 --- a/clutter/clutter/clutter-event.c +++ b/clutter/clutter/clutter-event.c @@ -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); } /** diff --git a/src/backends/native/meta-thread-impl.c b/src/backends/native/meta-thread-impl.c index d02d49203..c32790f40 100644 --- a/src/backends/native/meta-thread-impl.c +++ b/src/backends/native/meta-thread-impl.c @@ -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