13
0

move BaseUI::_name into EventLoop; rename access method in EventLoop as event_loop_name() to clarify usage

This commit is contained in:
Paul Davis 2015-12-12 10:55:40 -05:00
parent 6b00ff6198
commit f369f33955
4 changed files with 14 additions and 9 deletions

View File

@ -47,10 +47,10 @@ uint64_t BaseUI::rt_bit = 1;
BaseUI::RequestType BaseUI::CallSlot = BaseUI::new_request_type();
BaseUI::RequestType BaseUI::Quit = BaseUI::new_request_type();
BaseUI::BaseUI (const string& str)
: m_context(MainContext::get_default())
BaseUI::BaseUI (const string& loop_name)
: EventLoop (loop_name)
, m_context(MainContext::get_default())
, run_loop_thread (0)
, _name (str)
, request_channel (true)
{
base_ui_instance = this;
@ -79,7 +79,7 @@ BaseUI::new_request_type ()
void
BaseUI::main_thread ()
{
DEBUG_TRACE (DEBUG::EventLoop, string_compose ("%1: event loop running in thread %2\n", name(), pthread_name()));
DEBUG_TRACE (DEBUG::EventLoop, string_compose ("%1: event loop running in thread %2\n", event_loop_name(), pthread_name()));
set_event_loop_for_thread (this);
thread_init ();
_main_loop->get_context()->signal_idle().connect (sigc::mem_fun (*this, &BaseUI::signal_running));

View File

@ -27,6 +27,11 @@ static void do_not_delete_the_loop_pointer (void*) { }
Glib::Threads::Private<EventLoop> EventLoop::thread_event_loop (do_not_delete_the_loop_pointer);
EventLoop::EventLoop (string const& name)
: _name (name)
{
}
EventLoop*
EventLoop::get_event_loop_for_thread() {
return thread_event_loop.get ();

View File

@ -54,8 +54,6 @@ class LIBPBD_API BaseUI : public sigc::trackable, public PBD::EventLoop
Glib::Threads::Thread* event_loop_thread() const { return run_loop_thread; }
bool caller_is_self () const { return Glib::Threads::Thread::self() == run_loop_thread; }
std::string name() const { return _name; }
bool ok() const { return _ok; }
static RequestType new_request_type();
@ -107,7 +105,6 @@ class LIBPBD_API BaseUI : public sigc::trackable, public PBD::EventLoop
virtual void handle_ui_requests () = 0;
private:
std::string _name;
BaseUI* base_ui_instance;
CrossThreadChannel request_channel;

View File

@ -20,6 +20,7 @@
#ifndef __pbd_event_loop_h__
#define __pbd_event_loop_h__
#include <string>
#include <boost/function.hpp>
#include <boost/bind.hpp> /* we don't need this here, but anything calling call_slot() probably will, so this is convenient */
#include <glibmm/threads.h>
@ -41,7 +42,7 @@ namespace PBD
class LIBPBD_API EventLoop
{
public:
EventLoop() {}
EventLoop (std::string const&);
virtual ~EventLoop() {}
enum RequestType {
@ -73,12 +74,14 @@ class LIBPBD_API EventLoop
virtual void call_slot (InvalidationRecord*, const boost::function<void()>&) = 0;
virtual Glib::Threads::Mutex& slot_invalidation_mutex() = 0;
std::string event_loop_name() const { return _name; }
static EventLoop* get_event_loop_for_thread();
static void set_event_loop_for_thread (EventLoop* ui);
private:
static Glib::Threads::Private<EventLoop> thread_event_loop;
std::string _name;
};
}