2 #include "pbd/event_loop.h"
3 #include "pbd/stacktrace.h"
8 Glib::StaticPrivate<EventLoop> EventLoop::thread_event_loop;
10 static void do_not_delete_the_loop_pointer (void*) { }
13 EventLoop::get_event_loop_for_thread() {
14 return thread_event_loop.get ();
18 EventLoop::set_event_loop_for_thread (EventLoop* loop)
20 thread_event_loop.set (loop, do_not_delete_the_loop_pointer);
24 EventLoop::invalidate_request (void* data)
26 InvalidationRecord* ir = (InvalidationRecord*) data;
28 /* Some of the requests queued with an EventLoop may involve functors
29 * that make method calls to objects whose lifetime is shorter
30 * than the EventLoop's. We do not want to make those calls if the
31 * object involve has been destroyed. To prevent this, we
32 * provide a way to invalidate those requests when the object is
35 * An object was passed to __invalidator() which added a callback to
36 * EventLoop::invalidate_request() to its "notify when destroyed"
37 * list. __invalidator() returned an InvalidationRecord that has been
38 * to passed to this function as data.
40 * The object is currently being destroyed and so we want to
41 * mark all requests involving this object that are queued with
42 * any EventLoop as invalid.
44 * As of April 2012, we are usign sigc::trackable as the base object
45 * used to queue calls to ::invalidate_request() to be made upon
46 * destruction, via its ::add_destroy_notify_callback() API. This is
47 * not necessarily ideal, but it is very close to precisely what we
48 * want, and many of the objects we want to do this with already
49 * inherit (indirectly) from sigc::trackable.
53 Glib::Mutex::Lock lm (ir->event_loop->slot_invalidation_mutex());
54 for (list<BaseRequestObject*>::iterator i = ir->requests.begin(); i != ir->requests.end(); ++i) {
56 (*i)->invalidation = 0;