Deprecate clutter_threads_enter()/leave()

Acquiring the Clutter lock to mark critical sections is not portable,
and not recommended to implement threaded applications with Clutter.

The recommended pattern is to use worker threads, and schedule UI
updates inside idle or timeout handlers within the main loop. We should
enforce this pattern by deprecating the threads_enter()/leave()
functions. For compatibility concerns, we need internal API to acquire
the main lock during frame processing dispatch.

https://bugzilla.gnome.org/show_bug.cgi?id=679450
This commit is contained in:
Emmanuele Bassi
2012-07-05 14:30:26 +01:00
parent 25be8e86f7
commit 0e4c6d0a87
13 changed files with 107 additions and 67 deletions

View File

@ -173,12 +173,12 @@ clutter_event_prepare (GSource *source,
{
gboolean retval;
clutter_threads_enter ();
_clutter_threads_acquire_lock ();
*timeout = -1;
retval = clutter_events_pending ();
clutter_threads_leave ();
_clutter_threads_release_lock ();
return retval;
}
@ -189,12 +189,12 @@ clutter_event_check (GSource *source)
ClutterEventSource *event_source = (ClutterEventSource *) source;
gboolean retval;
clutter_threads_enter ();
_clutter_threads_acquire_lock ();
retval = ((event_source->event_poll_fd.revents & G_IO_IN) ||
clutter_events_pending ());
clutter_threads_leave ();
_clutter_threads_release_lock ();
return retval;
}
@ -208,7 +208,7 @@ clutter_event_dispatch (GSource *source,
struct ts_sample tsevent;
ClutterEvent *event;
clutter_threads_enter ();
_clutter_threads_acquire_lock ();
/* FIXME while would be better here but need to deal with lockups */
if ((!clutter_events_pending()) &&
@ -272,8 +272,7 @@ clutter_event_dispatch (GSource *source,
}
out:
clutter_threads_leave ();
_clutter_threads_release_lock ();
return TRUE;
}