From 515ffbdfe2c1537897dd0f46c57d443dbc812444 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 6 Jun 2020 18:32:09 +0200 Subject: [PATCH] Add API to create threads with given stacksize --- libs/pbd/pbd/pthread_utils.h | 7 +++++++ libs/pbd/pthread_utils.cc | 20 ++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/libs/pbd/pbd/pthread_utils.h b/libs/pbd/pbd/pthread_utils.h index 6eedbd95c8..c2bd49ccb6 100644 --- a/libs/pbd/pbd/pthread_utils.h +++ b/libs/pbd/pbd/pthread_utils.h @@ -65,6 +65,13 @@ LIBPBD_API void pthread_kill_all (int signum); LIBPBD_API const char* pthread_name (); LIBPBD_API void pthread_set_name (const char* name); +LIBPBD_API int pbd_pthread_create ( + const size_t stacksize, + pthread_t *thread, + void *(*start_routine) (void *), + void *arg); + + LIBPBD_API int pbd_realtime_pthread_create ( const int policy, int priority, const size_t stacksize, pthread_t *thread, diff --git a/libs/pbd/pthread_utils.cc b/libs/pbd/pthread_utils.cc index 1d179f9cac..5db2a71252 100644 --- a/libs/pbd/pthread_utils.cc +++ b/libs/pbd/pthread_utils.cc @@ -222,6 +222,23 @@ pthread_cancel_one (pthread_t thread) pthread_mutex_unlock (&thread_map_lock); } +int +pbd_pthread_create ( + const size_t stacksize, + pthread_t *thread, + void *(*start_routine) (void *), + void *arg) +{ + int rv; + + pthread_attr_t attr; + pthread_attr_init (&attr); + pthread_attr_setstacksize (&attr, stacksize); + rv = pthread_create (thread, &attr, start_routine, arg); + pthread_attr_destroy (&attr); + return rv; +} + int pbd_absolute_rt_priority (int policy, int priority) { @@ -246,8 +263,6 @@ pbd_absolute_rt_priority (int policy, int priority) return priority; } - - int pbd_realtime_pthread_create ( const int policy, int priority, const size_t stacksize, @@ -272,6 +287,7 @@ pbd_realtime_pthread_create ( pthread_attr_destroy (&attr); return rv; } + int pbd_set_thread_priority (pthread_t thread, const int policy, int priority) {