summaryrefslogtreecommitdiffstats
path: root/osdep/threads.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-05-18 16:36:08 +0200
committerwm4 <wm4@nowhere>2014-05-18 19:20:32 +0200
commitf47a4fc3d900e14653bc059717e2805ad4964a67 (patch)
treea8ca8944a10c15bbb46239db62a56940a0d3f7b1 /osdep/threads.h
parente209e44ca2fef86ec2ec5513bbb63d4d68ff97b5 (diff)
downloadmpv-f47a4fc3d900e14653bc059717e2805ad4964a67.tar.bz2
mpv-f47a4fc3d900e14653bc059717e2805ad4964a67.tar.xz
threads: use mpv time for mpthread_cond_timedwait wrapper
Use the time as returned by mp_time_us() for mpthread_cond_timedwait(), instead of calculating the struct timespec value based on a timeout. This (probably) makes it easier to wait for a specific deadline.
Diffstat (limited to 'osdep/threads.h')
-rw-r--r--osdep/threads.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/osdep/threads.h b/osdep/threads.h
index 02f6ac1489..fa9199d63d 100644
--- a/osdep/threads.h
+++ b/osdep/threads.h
@@ -2,12 +2,18 @@
#define MP_OSDEP_THREADS_H_
#include <pthread.h>
+#include <inttypes.h>
-struct timespec mpthread_get_deadline(double timeout);
-
+// Call pthread_cond_timedwait() with an absolute timeout using the same
+// time source/unit as mp_time_us() (microseconds).
int mpthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
- double timeout);
+ int64_t abstime);
+
+// Wait by a relative amount of time in seconds.
+int mpthread_cond_timedwait_rel(pthread_cond_t *cond, pthread_mutex_t *mutex,
+ double seconds);
+// Helper to reduce boiler plate.
int mpthread_mutex_init_recursive(pthread_mutex_t *mutex);
#endif