Replace Glib::Threads with PBD::Thread (2/2)
This commit is contained in:
parent
24bbf403b9
commit
50abcc74b5
|
@ -37,7 +37,7 @@ TestUI::TestUI ()
|
|||
|
||||
pthread_set_name ("test_ui_thread");
|
||||
|
||||
run_loop_thread = Glib::Threads::Thread::self ();
|
||||
_run_loop_thread = PBD::Thread::self ();
|
||||
|
||||
set_event_loop_for_thread (this);
|
||||
|
||||
|
|
|
@ -96,10 +96,9 @@ UI::UI (string application_name, string thread_name, int *argc, char ***argv)
|
|||
}
|
||||
|
||||
/* the GUI event loop runs in the main thread of the app,
|
||||
which is assumed to have called this.
|
||||
*/
|
||||
|
||||
run_loop_thread = Threads::Thread::self();
|
||||
* which is assumed to have called this.
|
||||
*/
|
||||
_run_loop_thread = PBD::Thread::self ();
|
||||
|
||||
/* store "this" as the UI-for-thread of this thread, same argument
|
||||
as for previous line.
|
||||
|
@ -144,9 +143,9 @@ UI::~UI ()
|
|||
}
|
||||
|
||||
bool
|
||||
UI::caller_is_ui_thread ()
|
||||
UI::caller_is_ui_thread () const
|
||||
{
|
||||
return Threads::Thread::self() == run_loop_thread;
|
||||
return caller_is_self ();
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -129,7 +129,7 @@ public:
|
|||
|
||||
/* Abstract UI interfaces */
|
||||
|
||||
bool caller_is_ui_thread ();
|
||||
bool caller_is_ui_thread () const;
|
||||
|
||||
/* Gtk-UI specific interfaces */
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ BaseUI::RequestType BaseUI::Quit = BaseUI::new_request_type();
|
|||
BaseUI::BaseUI (const string& loop_name)
|
||||
: EventLoop (loop_name)
|
||||
, m_context(MainContext::get_default())
|
||||
, run_loop_thread (0)
|
||||
, _run_loop_thread (0)
|
||||
, request_channel (true)
|
||||
{
|
||||
base_ui_instance = this;
|
||||
|
@ -69,6 +69,7 @@ BaseUI::BaseUI (const string& loop_name)
|
|||
|
||||
BaseUI::~BaseUI()
|
||||
{
|
||||
delete _run_loop_thread;
|
||||
}
|
||||
|
||||
BaseUI::RequestType
|
||||
|
@ -121,7 +122,7 @@ BaseUI::run ()
|
|||
attach_request_source ();
|
||||
|
||||
Glib::Threads::Mutex::Lock lm (_run_lock);
|
||||
run_loop_thread = Glib::Threads::Thread::create (mem_fun (*this, &BaseUI::main_thread));
|
||||
_run_loop_thread = PBD::Thread::create (boost::bind (&BaseUI::main_thread, this));
|
||||
_running.wait (_run_lock);
|
||||
}
|
||||
|
||||
|
@ -130,7 +131,7 @@ BaseUI::quit ()
|
|||
{
|
||||
if (_main_loop && _main_loop->is_running()) {
|
||||
_main_loop->quit ();
|
||||
run_loop_thread->join ();
|
||||
_run_loop_thread->join ();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,8 +53,7 @@ class LIBPBD_API BaseUI : public sigc::trackable, public PBD::EventLoop
|
|||
BaseUI* base_instance() { return base_ui_instance; }
|
||||
|
||||
Glib::RefPtr<Glib::MainLoop> main_loop() const { return _main_loop; }
|
||||
Glib::Threads::Thread* event_loop_thread() const { return run_loop_thread; }
|
||||
bool caller_is_self () const { return Glib::Threads::Thread::self() == run_loop_thread; }
|
||||
bool caller_is_self () const { assert (_run_loop_thread); return _run_loop_thread->caller_is_self (); }
|
||||
|
||||
bool ok() const { return _ok; }
|
||||
|
||||
|
@ -80,7 +79,7 @@ class LIBPBD_API BaseUI : public sigc::trackable, public PBD::EventLoop
|
|||
|
||||
Glib::RefPtr<Glib::MainLoop> _main_loop;
|
||||
Glib::RefPtr<Glib::MainContext> m_context;
|
||||
Glib::Threads::Thread* run_loop_thread;
|
||||
PBD::Thread* _run_loop_thread;
|
||||
Glib::Threads::Mutex _run_lock;
|
||||
Glib::Threads::Cond _running;
|
||||
|
||||
|
|
Loading…
Reference in New Issue