summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2010-10-24 09:37:43 +0200
committerGravatar waker <wakeroid@gmail.com>2010-10-24 09:37:43 +0200
commitc3f898dd52bc4eda6ae76b7e618fce86f35fad79 (patch)
treef13b4f4d5a9448453b5ed6ccc4fa0b02bb7e5d4b
parent36d81fe36ea5b505ebe2536809728497f960b815 (diff)
added thread_detach and thread_exit APIs
-rw-r--r--deadbeef.h2
-rw-r--r--plugins.c2
-rw-r--r--threading.h6
-rw-r--r--threading_pthread.c15
4 files changed, 25 insertions, 0 deletions
diff --git a/deadbeef.h b/deadbeef.h
index 337219ed..8ea30059 100644
--- a/deadbeef.h
+++ b/deadbeef.h
@@ -324,6 +324,8 @@ typedef struct {
intptr_t (*thread_start) (void (*fn)(void *ctx), void *ctx);
intptr_t (*thread_start_low_priority) (void (*fn)(void *ctx), void *ctx);
int (*thread_join) (intptr_t tid);
+ int (*thread_detach) (intptr_t tid);
+ void (*thread_exit) (void *retval);
uintptr_t (*mutex_create) (void);
uintptr_t (*mutex_create_nonrecursive) (void);
void (*mutex_free) (uintptr_t mtx);
diff --git a/plugins.c b/plugins.c
index 331baab9..35522e17 100644
--- a/plugins.c
+++ b/plugins.c
@@ -95,6 +95,8 @@ static DB_functions_t deadbeef_api = {
.thread_start = thread_start,
.thread_start_low_priority = thread_start_low_priority,
.thread_join = thread_join,
+ .thread_detach = thread_detach,
+ .thread_exit = thread_exit,
.mutex_create = mutex_create,
.mutex_create_nonrecursive = mutex_create_nonrecursive,
.mutex_free = mutex_free,
diff --git a/threading.h b/threading.h
index dee1cc3c..6ceca641 100644
--- a/threading.h
+++ b/threading.h
@@ -29,6 +29,12 @@ thread_start_low_priority (void (*fn)(void *ctx), void *ctx);
int
thread_join (intptr_t tid);
+int
+thread_detach (intptr_t tid);
+
+void
+thread_exit (void *retval);
+
uintptr_t
mutex_create (void);
diff --git a/threading_pthread.c b/threading_pthread.c
index 66db5844..13d12b94 100644
--- a/threading_pthread.c
+++ b/threading_pthread.c
@@ -99,6 +99,21 @@ thread_join (intptr_t tid) {
return 0;
}
+int
+thread_detach (intptr_t tid) {
+ int s = pthread_detach ((pthread_t)tid);
+ if (s) {
+ fprintf (stderr, "pthread_detach failed: %s\n", strerror (s));
+ return -1;
+ }
+ return 0;
+}
+
+void
+thread_exit (void *retval) {
+ pthread_exit (retval);
+}
+
uintptr_t
mutex_create_nonrecursive (void) {
pthread_mutex_t *mtx = malloc (sizeof (pthread_mutex_t));