summaryrefslogtreecommitdiffstats
path: root/osdep/threads.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-02-02 17:06:49 +0100
committerwm4 <wm4@nowhere>2014-02-10 00:04:39 +0100
commit20fbe2fb8c1b3b4f5b08dd529ac1897f24c88a95 (patch)
tree46d609915932125f402061370e17f2f8039244d0 /osdep/threads.h
parentdd264ebe9d00c8cb22ed4d931d31293ff5b3cece (diff)
downloadmpv-20fbe2fb8c1b3b4f5b08dd529ac1897f24c88a95.tar.bz2
mpv-20fbe2fb8c1b3b4f5b08dd529ac1897f24c88a95.tar.xz
threads: add a dispatch queue thing
Makes working with the (still) single-threaded playback thread easier. Might be reusable for other stuff.
Diffstat (limited to 'osdep/threads.h')
-rw-r--r--osdep/threads.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/osdep/threads.h b/osdep/threads.h
index 3d060009cb..3eb4ce2ffc 100644
--- a/osdep/threads.h
+++ b/osdep/threads.h
@@ -1,6 +1,7 @@
#ifndef MP_OSDEP_THREADS_H_
#define MP_OSDEP_THREADS_H_
+#include <stdbool.h>
#include <pthread.h>
struct timespec mpthread_get_deadline(double timeout);
@@ -10,4 +11,24 @@ int mpthread_cond_timed_wait(pthread_cond_t *cond, pthread_mutex_t *mutex,
int mpthread_mutex_init_recursive(pthread_mutex_t *mutex);
+
+typedef void (*mp_dispatch_fn)(void *data);
+struct mp_dispatch_queue;
+
+struct mp_dispatch_queue *mp_dispatch_create(void *talloc_parent);
+void mp_dispatch_set_wakeup_fn(struct mp_dispatch_queue *queue,
+ void (*wakeup_fn)(void *wakeup_ctx),
+ void *wakeup_ctx);
+void mp_dispatch_enqueue(struct mp_dispatch_queue *queue,
+ mp_dispatch_fn fn, void *fn_data);
+void mp_dispatch_enqueue_autofree(struct mp_dispatch_queue *queue,
+ mp_dispatch_fn fn, void *fn_data);
+void mp_dispatch_run(struct mp_dispatch_queue *queue,
+ mp_dispatch_fn fn, void *fn_data);
+void mp_dispatch_queue_process(struct mp_dispatch_queue *queue, double timeout);
+void mp_dispatch_suspend(struct mp_dispatch_queue *queue);
+void mp_dispatch_resume(struct mp_dispatch_queue *queue);
+void mp_dispatch_lock(struct mp_dispatch_queue *queue);
+void mp_dispatch_unlock(struct mp_dispatch_queue *queue);
+
#endif