From f369f339555e5700c5edd13b351c22fa1a91bb4b Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 12 Dec 2015 10:55:40 -0500 Subject: move BaseUI::_name into EventLoop; rename access method in EventLoop as event_loop_name() to clarify usage --- libs/pbd/base_ui.cc | 8 ++++---- libs/pbd/event_loop.cc | 5 +++++ libs/pbd/pbd/base_ui.h | 3 --- libs/pbd/pbd/event_loop.h | 7 +++++-- 4 files changed, 14 insertions(+), 9 deletions(-) (limited to 'libs') diff --git a/libs/pbd/base_ui.cc b/libs/pbd/base_ui.cc index 09dfa74785..c56fb8f4fe 100644 --- a/libs/pbd/base_ui.cc +++ b/libs/pbd/base_ui.cc @@ -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)); diff --git a/libs/pbd/event_loop.cc b/libs/pbd/event_loop.cc index d3f2fe5038..95b43d9038 100644 --- a/libs/pbd/event_loop.cc +++ b/libs/pbd/event_loop.cc @@ -27,6 +27,11 @@ static void do_not_delete_the_loop_pointer (void*) { } Glib::Threads::Private 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 (); diff --git a/libs/pbd/pbd/base_ui.h b/libs/pbd/pbd/base_ui.h index ec2cf33678..029d8223ea 100644 --- a/libs/pbd/pbd/base_ui.h +++ b/libs/pbd/pbd/base_ui.h @@ -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; diff --git a/libs/pbd/pbd/event_loop.h b/libs/pbd/pbd/event_loop.h index a100365497..3ea6388f3f 100644 --- a/libs/pbd/pbd/event_loop.h +++ b/libs/pbd/pbd/event_loop.h @@ -20,6 +20,7 @@ #ifndef __pbd_event_loop_h__ #define __pbd_event_loop_h__ +#include #include #include /* we don't need this here, but anything calling call_slot() probably will, so this is convenient */ #include @@ -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&) = 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 thread_event_loop; - + std::string _name; }; } -- cgit v1.2.3