2 Copyright (C) 1998-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_abstract_ui_h__
21 #define __pbd_abstract_ui_h__
27 #include <glibmm/thread.h>
29 #include "pbd/receiver.h"
30 #include "pbd/ringbufferNPT.h"
31 #include "pbd/signals.h"
32 #include "pbd/base_ui.h"
36 template<typename RequestObject>
37 class AbstractUI : public BaseUI
40 AbstractUI (const std::string& name);
41 virtual ~AbstractUI() {}
43 void register_thread (std::string, pthread_t, std::string, uint32_t num_requests);
44 void call_slot (EventLoop::InvalidationRecord*, const boost::function<void()>&);
45 Glib::Mutex& slot_invalidation_mutex() { return request_buffer_map_lock; }
48 typedef RingBufferNPT<RequestObject> RequestBuffer;
49 typedef typename RequestBuffer::rw_vector RequestBufferVector;
50 typedef typename std::map<pthread_t,RequestBuffer*>::iterator RequestBufferMapIterator;
51 typedef std::map<pthread_t,RequestBuffer*> RequestBufferMap;
53 Glib::Mutex request_buffer_map_lock;
54 RequestBufferMap request_buffers;
55 static Glib::StaticPrivate<RequestBuffer> per_thread_request_buffer;
57 Glib::Mutex request_list_lock;
58 std::list<RequestObject*> request_list;
60 RequestObject* get_request (RequestType);
61 void handle_ui_requests ();
62 void send_request (RequestObject *);
64 virtual void do_request (RequestObject *) = 0;
65 PBD::ScopedConnection new_thread_connection;
68 #endif /* __pbd_abstract_ui_h__ */