27 #ifdef WINE_THREAD_SUPPORT
32 DECLARE_DEFAULT_COMPARISONS(pthread_t)
44 static Glib::Threads::Private<char>
thread_name (free);
52 static int thread_creator (pthread_t* thread_id,
const pthread_attr_t* attr,
void *(*
function)(
void*),
void* arg)
54 #ifdef WINE_THREAD_SUPPORT
55 return wine_pthread_create (thread_id, attr,
function, arg);
68 void* (*thread_work)(
void*);
73 : thread_work (
f), arg (a), name (s) {}
81 void* thread_arg = ts->
arg;
93 void* ret = thread_work (thread_arg);
97 pthread_mutex_lock (&thread_map_lock);
99 for (ThreadMap::iterator i = all_threads.begin(); i != all_threads.end(); ++i) {
100 if (pthread_equal ((*i), pthread_self())) {
101 all_threads.erase (i);
106 pthread_mutex_unlock (&thread_map_lock);
116 pthread_attr_t default_attr;
120 pthread_attr_init(&default_attr);
121 pthread_attr_setstacksize(&default_attr, 500000);
126 pthread_mutex_lock (&thread_map_lock);
127 all_threads.push_back (*thread);
128 pthread_mutex_unlock (&thread_map_lock);
131 pthread_attr_destroy(&default_attr);
158 pthread_mutex_lock (&thread_map_lock);
159 for (ThreadMap::iterator i = all_threads.begin(); i != all_threads.end(); ++i) {
160 if (!pthread_equal ((*i), pthread_self())) {
161 pthread_kill ((*i), signum);
165 pthread_mutex_unlock (&thread_map_lock);
171 pthread_mutex_lock (&thread_map_lock);
173 for (ThreadMap::iterator i = all_threads.begin(); i != all_threads.end(); ) {
175 ThreadMap::iterator nxt = i;
178 if (!pthread_equal ((*i), pthread_self())) {
179 pthread_cancel ((*i));
185 pthread_mutex_unlock (&thread_map_lock);
191 pthread_mutex_lock (&thread_map_lock);
192 for (ThreadMap::iterator i = all_threads.begin(); i != all_threads.end(); ++i) {
193 if (pthread_equal ((*i), thread)) {
194 all_threads.erase (i);
199 pthread_cancel (thread);
200 pthread_mutex_unlock (&thread_map_lock);
std::list< pthread_t > ThreadMap
void pthread_set_name(const char *str)
int pthread_create_and_store(string name, pthread_t *thread, void *(*start_routine)(void *), void *arg)
static pthread_mutex_t thread_map_lock
LIBPBD_API void notify_gui_about_thread_creation(std::string, pthread_t, std::string, int requests=256)
static Glib::Threads::Private< char > thread_name(free)
void pthread_cancel_one(pthread_t thread)
void *(* thread_work)(void *)
void pthread_kill_all(int signum)
ThreadStartWithName(void *(*f)(void *), void *a, const std::string &s)
void pthread_cancel_all()
const char * pthread_name()
static void * fake_thread_start(void *arg)
static int thread_creator(pthread_t *thread_id, const pthread_attr_t *attr, void *(*function)(void *), void *arg)
static ThreadMap all_threads
int pthread_create(pthread_t *__restrict thread, __const pthread_attr_t *__restrict attr, void *(*start_routine)(void *), void *__restrict arg)
LIBPBD_API PBD::Signal4< void, std::string, pthread_t, std::string, uint32_t > ThreadCreatedWithRequestSize