diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2008-11-06 22:18:27 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2008-11-06 22:18:27 +0000 |
commit | 99aad0d4df5de53f71b7b43bd69e8affe615c971 (patch) | |
tree | 72811037315c3be00d9d49df6393a878123a7872 /libs/pbd | |
parent | d410d82ad893dbe02d2ea131c55706dec65dc256 (diff) |
wrap PBD::Thread... signals in a mutex to avoid crashing as multiple threads call it simultaneously; increase FUDGE distance for GTK/X11 when sizing comboboxselectors in editor
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@4099 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd')
-rw-r--r-- | libs/pbd/pbd/abstract_ui.cc | 1 | ||||
-rw-r--r-- | libs/pbd/pbd/pthread_utils.h | 8 | ||||
-rw-r--r-- | libs/pbd/pthread_utils.cc | 18 |
3 files changed, 22 insertions, 5 deletions
diff --git a/libs/pbd/pbd/abstract_ui.cc b/libs/pbd/pbd/abstract_ui.cc index 7b21390764..bc33fc9a39 100644 --- a/libs/pbd/pbd/abstract_ui.cc +++ b/libs/pbd/pbd/abstract_ui.cc @@ -17,7 +17,6 @@ AbstractUI<RequestObject>::AbstractUI (string name, bool with_signal_pipes) throw failed_constructor(); } - PBD::ThreadCreated.connect (mem_fun (*this, &AbstractUI<RequestObject>::register_thread)); PBD::ThreadLeaving.connect (mem_fun (*this, &AbstractUI<RequestObject>::unregister_thread)); PBD::ThreadCreatedWithRequestSize.connect (mem_fun (*this, &AbstractUI<RequestObject>::register_thread_with_request_count)); } diff --git a/libs/pbd/pbd/pthread_utils.h b/libs/pbd/pbd/pthread_utils.h index 157dab6c12..dd91e0a2b1 100644 --- a/libs/pbd/pbd/pthread_utils.h +++ b/libs/pbd/pbd/pthread_utils.h @@ -35,9 +35,11 @@ void pthread_exit_pbd (void* status); std::string pthread_name (); namespace PBD { - extern sigc::signal<void,pthread_t,std::string> ThreadCreated; - extern sigc::signal<void,pthread_t> ThreadLeaving; - extern sigc::signal<void,pthread_t,std::string,uint32_t> ThreadCreatedWithRequestSize; + extern void notify_gui_about_thread_creation (pthread_t, std::string, int requests = 256); + extern void notify_gui_about_thread_exit (pthread_t); + + extern sigc::signal<void,pthread_t> ThreadLeaving; + extern sigc::signal<void,pthread_t,std::string,uint32_t> ThreadCreatedWithRequestSize; } #endif /* __pbd_pthread_utils__ */ diff --git a/libs/pbd/pthread_utils.cc b/libs/pbd/pthread_utils.cc index 0c9d574e73..c63f988af3 100644 --- a/libs/pbd/pthread_utils.cc +++ b/libs/pbd/pthread_utils.cc @@ -30,15 +30,31 @@ using namespace std; typedef std::map<string,pthread_t> ThreadMap; static ThreadMap all_threads; static pthread_mutex_t thread_map_lock = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t gui_notify_lock = PTHREAD_MUTEX_INITIALIZER; namespace PBD { - sigc::signal<void,pthread_t,std::string> ThreadCreated; sigc::signal<void,pthread_t> ThreadLeaving; sigc::signal<void,pthread_t,std::string,uint32_t> ThreadCreatedWithRequestSize; } using namespace PBD; +void +PBD::notify_gui_about_thread_creation (pthread_t thread, std::string str, int request_count) +{ + pthread_mutex_lock (&gui_notify_lock); + ThreadCreatedWithRequestSize (thread, str, request_count); + pthread_mutex_unlock (&gui_notify_lock); +} + +void +PBD::notify_gui_about_thread_exit (pthread_t thread) +{ + pthread_mutex_lock (&gui_notify_lock); + ThreadLeaving (thread); + pthread_mutex_unlock (&gui_notify_lock); +} + int pthread_create_and_store (string name, pthread_t *thread, pthread_attr_t *attr, void * (*start_routine)(void *), void * arg) { |