diff options
author | Jonas Ådahl <jadahl@gmail.com> | 2020-05-23 22:50:43 +0200 |
---|---|---|
committer | Jonas Ådahl <jadahl@gmail.com> | 2020-07-02 19:36:51 +0200 |
commit | de99dd7eb6555836611f7c93343410e7cbd67aba (patch) | |
tree | 7cad953fd3bcbfabd8ff7531244d3b547733f9d6 /clutter/clutter/clutter-main.c | |
parent | 34be97d855865906937282b56f4bb7bc94ab17a0 (diff) | |
download | mutter-de99dd7eb6555836611f7c93343410e7cbd67aba.tar.gz |
clutter: Remove multi thread mutexes
The mutexes was used by ClutterTexture's async upload and to match GDK's
mutexes on X11. GDK's X11 connection does not share anything with
Clutter's, we don't have the Gdk Clutter backend left, and we have
already removed ClutterTexture, so lets remove these mutexes as well.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
Diffstat (limited to 'clutter/clutter/clutter-main.c')
-rw-r--r-- | clutter/clutter/clutter-main.c | 87 |
1 files changed, 5 insertions, 82 deletions
diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c index 0da859d60..d052b1474 100644 --- a/clutter/clutter/clutter-main.c +++ b/clutter/clutter/clutter-main.c @@ -83,10 +83,6 @@ /* main context */ static ClutterMainContext *ClutterCntx = NULL; -G_LOCK_DEFINE_STATIC (ClutterCntx); - -/* main lock and locking/unlocking functions */ -static GMutex clutter_threads_mutex; /* command line options */ static gboolean clutter_is_initialized = FALSE; @@ -145,12 +141,6 @@ static const GDebugKey clutter_paint_debug_keys[] = { { "damage-region", CLUTTER_DEBUG_PAINT_DAMAGE_REGION }, }; -static inline void -clutter_threads_init_default (void) -{ - g_mutex_init (&clutter_threads_mutex); -} - #define ENVIRONMENT_GROUP "Environment" #define DEBUG_GROUP "Debug" @@ -519,11 +509,7 @@ clutter_main (void) main_loops = g_slist_prepend (main_loops, loop); if (g_main_loop_is_running (main_loops->data)) - { - _clutter_threads_release_lock (); - g_main_loop_run (loop); - _clutter_threads_acquire_lock (); - } + g_main_loop_run (loop); main_loops = g_slist_remove (main_loops, loop); @@ -540,13 +526,9 @@ _clutter_threads_dispatch (gpointer data) ClutterThreadsDispatch *dispatch = data; gboolean ret = FALSE; - _clutter_threads_acquire_lock (); - if (!g_source_is_destroyed (g_main_current_source ())) ret = dispatch->func (dispatch->data); - _clutter_threads_release_lock (); - return ret; } @@ -771,40 +753,6 @@ clutter_threads_add_timeout (guint interval, NULL); } -void -_clutter_threads_acquire_lock (void) -{ - g_mutex_lock (&clutter_threads_mutex); -} - -void -_clutter_threads_release_lock (void) -{ - /* we need to trylock here, in case the lock hasn't been acquired; on - * various systems trying to release a mutex that hasn't been acquired - * will cause a run-time error. trylock() will either fail, in which - * case we can release the lock we own; or it will succeeds, in which - * case we need to release the lock we just acquired. so we ignore the - * returned value. - * - * see: https://bugs.gnome.org/679439 - */ - g_mutex_trylock (&clutter_threads_mutex); - g_mutex_unlock (&clutter_threads_mutex); -} - -void -_clutter_context_lock (void) -{ - G_LOCK (ClutterCntx); -} - -void -_clutter_context_unlock (void) -{ - G_UNLOCK (ClutterCntx); -} - gboolean _clutter_context_is_initialized (void) { @@ -814,8 +762,8 @@ _clutter_context_is_initialized (void) return ClutterCntx->is_initialized; } -static ClutterMainContext * -clutter_context_get_default_unlocked (void) +ClutterMainContext * +_clutter_context_get_default (void) { if (G_UNLIKELY (ClutterCntx == NULL)) { @@ -846,20 +794,6 @@ clutter_context_get_default_unlocked (void) return ClutterCntx; } -ClutterMainContext * -_clutter_context_get_default (void) -{ - ClutterMainContext *retval; - - _clutter_context_lock (); - - retval = clutter_context_get_default_unlocked (); - - _clutter_context_unlock (); - - return retval; -} - static gboolean clutter_arg_direction_cb (const char *key, const char *value, @@ -2170,9 +2104,6 @@ clutter_base_init (void) g_type_init (); #endif - /* initialise the Big Clutter Lock™ if necessary */ - clutter_threads_init_default (); - clutter_graphene_init (); } } @@ -2240,9 +2171,7 @@ clutter_threads_remove_repaint_func (guint handle_id) g_return_if_fail (handle_id > 0); - _clutter_context_lock (); - - context = clutter_context_get_default_unlocked (); + context = _clutter_context_get_default (); l = context->repaint_funcs; while (l != NULL) { @@ -2265,8 +2194,6 @@ clutter_threads_remove_repaint_func (guint handle_id) l = l->next; } - - _clutter_context_unlock (); } /** @@ -2365,9 +2292,7 @@ clutter_threads_add_repaint_func_full (ClutterRepaintFlags flags, g_return_val_if_fail (func != NULL, 0); - _clutter_context_lock (); - - context = clutter_context_get_default_unlocked (); + context = _clutter_context_get_default (); repaint_func = g_slice_new (ClutterRepaintFunction); @@ -2381,8 +2306,6 @@ clutter_threads_add_repaint_func_full (ClutterRepaintFlags flags, context->repaint_funcs = g_list_prepend (context->repaint_funcs, repaint_func); - _clutter_context_unlock (); - return repaint_func->id; } |