mirror of
https://github.com/brl/mutter.git
synced 2025-08-04 23:54:40 +00:00
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:
@@ -32,7 +32,9 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <unistd.h>
|
||||
#include <clutter/clutter-debug.h>
|
||||
|
||||
#include "clutter-debug.h"
|
||||
#include "clutter-private.h"
|
||||
|
||||
/*
|
||||
* This file implementations integration between the GLib main loop and
|
||||
@@ -643,13 +645,13 @@ clutter_event_prepare (GSource *source,
|
||||
{
|
||||
gboolean retval;
|
||||
|
||||
clutter_threads_enter ();
|
||||
_clutter_threads_acquire_lock ();
|
||||
|
||||
*timeout = -1;
|
||||
|
||||
retval = (clutter_events_pending () || _clutter_osx_event_loop_check_pending ());
|
||||
|
||||
clutter_threads_leave ();
|
||||
_clutter_threads_release_lock ();
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -659,7 +661,7 @@ clutter_event_check (GSource *source)
|
||||
{
|
||||
gboolean retval;
|
||||
|
||||
clutter_threads_enter ();
|
||||
_clutter_threads_acquire_lock ();
|
||||
|
||||
/* XXX: This check isn't right it won't handle a recursive GLib main
|
||||
* loop run within an outer CFRunLoop run. Such loops will pile up
|
||||
@@ -678,7 +680,7 @@ clutter_event_check (GSource *source)
|
||||
|
||||
retval = (clutter_events_pending () || _clutter_osx_event_loop_check_pending ());
|
||||
|
||||
clutter_threads_leave ();
|
||||
_clutter_threads_release_lock ();
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -691,16 +693,19 @@ clutter_event_dispatch (GSource *source,
|
||||
NSEvent *nsevent;
|
||||
ClutterEvent *event;
|
||||
|
||||
clutter_threads_enter ();
|
||||
_clutter_threads_acquire_lock ();
|
||||
|
||||
nsevent = _clutter_osx_event_loop_get_pending ();
|
||||
if (nsevent) {
|
||||
clutter_threads_leave ();
|
||||
[NSApp sendEvent:nsevent];
|
||||
clutter_threads_enter ();
|
||||
|
||||
_clutter_osx_event_loop_release_event (nsevent);
|
||||
}
|
||||
if (nsevent)
|
||||
{
|
||||
_clutter_threads_release_lock ();
|
||||
|
||||
[NSApp sendEvent:nsevent];
|
||||
|
||||
_clutter_threads_acquire_lock ();
|
||||
|
||||
_clutter_osx_event_loop_release_event (nsevent);
|
||||
}
|
||||
|
||||
event = clutter_event_get ();
|
||||
|
||||
@@ -711,7 +716,7 @@ clutter_event_dispatch (GSource *source,
|
||||
clutter_event_free (event);
|
||||
}
|
||||
|
||||
clutter_threads_leave ();
|
||||
_clutter_threads_release_lock ();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user