pa_threaded_mainloop_in_thread;
pa_threaded_mainloop_lock;
pa_threaded_mainloop_new;
+pa_threaded_mainloop_set_name;
pa_threaded_mainloop_signal;
pa_threaded_mainloop_start;
pa_threaded_mainloop_stop;
pa_thread* thread;
pa_mutex* mutex;
pa_cond* cond, *accept_cond;
+
+ char *name;
};
static inline int in_worker(pa_threaded_mainloop *m) {
m->cond = pa_cond_new();
m->accept_cond = pa_cond_new();
m->thread = NULL;
+ m->name = NULL;
pa_mainloop_set_poll_func(m->real_mainloop, poll_func, m->mutex);
pa_cond_free(m->cond);
pa_cond_free(m->accept_cond);
+ pa_xfree(m->name);
pa_xfree(m);
}
pa_assert(!m->thread || !pa_thread_is_running(m->thread));
- if (!(m->thread = pa_thread_new("threaded-ml", thread, m)))
+ if (!(m->thread = pa_thread_new(m->name ? m->name : "threaded-ml", thread, m)))
return -1;
return 0;
return m->thread && pa_thread_self() == m->thread;
}
+
+void pa_threaded_mainloop_set_name(pa_threaded_mainloop *m, const char *name) {
+ pa_assert(m);
+ pa_assert(name);
+
+ m->name = pa_xstrdup(name);
+
+ if (m->thread)
+ pa_thread_set_name(m->thread, m->name);
+}
/** Returns non-zero when called from within the event loop thread. \since 0.9.7 */
int pa_threaded_mainloop_in_thread(pa_threaded_mainloop *m);
+/** Sets the name of the thread. \since 4.0 */
+void pa_threaded_mainloop_set_name(pa_threaded_mainloop *m, const char *name);
+
PA_C_DECL_END
#endif