Add API to create threads with given stacksize

This commit is contained in:
Robin Gareus 2020-06-06 18:32:09 +02:00
parent 9398a6f60a
commit 515ffbdfe2
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 25 additions and 2 deletions

View File

@ -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,

View File

@ -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)
{