2
Copyright (C) 2009 Paul Davis
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or
7
(at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
#ifndef __pbd_event_loop_h__
21
#define __pbd_event_loop_h__
23
#include <boost/function.hpp>
24
#include <boost/bind.hpp> /* we don't need this here, but anything calling call_slot() probably will, so this is convenient */
25
#include <glibmm/threads.h>
30
/** An EventLoop is as basic abstraction designed to be used with any "user
31
* interface" (not necessarily graphical) that needs to wait on
32
* events/requests and dispatch/process them as they arrive.
34
* This is a very basic class that doesn't by itself provide an actual
35
* event loop or thread. See BaseUI for the "real" object to be used
36
* when something like this is needed (it inherits from EventLoop).
43
virtual ~EventLoop() {}
49
struct BaseRequestObject;
51
struct InvalidationRecord {
52
std::list<BaseRequestObject*> requests;
53
PBD::EventLoop* event_loop;
57
InvalidationRecord() : event_loop (0) {}
60
static void* invalidate_request (void* data);
62
struct BaseRequestObject {
65
InvalidationRecord* invalidation;
66
boost::function<void()> the_slot;
68
BaseRequestObject() : valid (true), invalidation (0) {}
71
virtual void call_slot (InvalidationRecord*, const boost::function<void()>&) = 0;
72
virtual Glib::Threads::Mutex& slot_invalidation_mutex() = 0;
74
static EventLoop* get_event_loop_for_thread();
75
static void set_event_loop_for_thread (EventLoop* ui);
78
static Glib::Threads::Private<EventLoop> thread_event_loop;
84
#define MISSING_INVALIDATOR 0 // used to mark places where we fail to provide an invalidator
86
#endif /* __pbd_event_loop_h__ */