ardour
event_loop.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 Paul Davis
3 
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.
8 
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.
13 
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.
17 
18 */
19 
20 #ifndef __pbd_event_loop_h__
21 #define __pbd_event_loop_h__
22 
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>
26 
27 #include "pbd/libpbd_visibility.h"
28 
29 namespace PBD
30 {
31 
42 {
43  public:
44  EventLoop() {}
45  virtual ~EventLoop() {}
46 
47  enum RequestType {
48  range_guarantee = ~0
49  };
50 
51  struct BaseRequestObject;
52 
54  std::list<BaseRequestObject*> requests;
56  const char* file;
57  int line;
58 
59  InvalidationRecord() : event_loop (0) {}
60  };
61 
62  static void* invalidate_request (void* data);
63 
66  bool valid;
68  boost::function<void()> the_slot;
69 
70  BaseRequestObject() : valid (true), invalidation (0) {}
71  };
72 
73  virtual void call_slot (InvalidationRecord*, const boost::function<void()>&) = 0;
74  virtual Glib::Threads::Mutex& slot_invalidation_mutex() = 0;
75 
76  static EventLoop* get_event_loop_for_thread();
77  static void set_event_loop_for_thread (EventLoop* ui);
78 
79  private:
80  static Glib::Threads::Private<EventLoop> thread_event_loop;
81 
82 };
83 
84 }
85 
86 #define MISSING_INVALIDATOR 0 // used to mark places where we fail to provide an invalidator
87 
88 #endif /* __pbd_event_loop_h__ */
static ARDOUR_UI * ui
Definition: main.cc:76
InvalidationRecord * invalidation
Definition: event_loop.h:67
boost::function< void()> the_slot
Definition: event_loop.h:68
#define LIBPBD_API
static Glib::Threads::Private< EventLoop > thread_event_loop
Definition: event_loop.h:80
std::list< BaseRequestObject * > requests
Definition: event_loop.h:54
Definition: debug.h:30
virtual ~EventLoop()
Definition: event_loop.h:45