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