1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-21 22:30:22 +00:00
mpv/osdep/threads.h
wm4 d8dd9a6725 threads: add function to calculate deadline for timed waits
Usually, you have to call pthread_cond_timedwait() in a loop (because it
can wake up sporadically). If this function is used by another higher
level function, which uses a relative timeout, we actually have to
reduce the timeout on each iteration - or, simpler, compute the
"deadline" at the beginning of the function, and always pass the same
absolute time to the waiting function.

Might be unsafe if the system time is changed. On the other hand, this
is a fundamental race condition with these APIs.
2014-01-31 22:17:43 +01:00

14 lines
324 B
C

#ifndef MP_OSDEP_THREADS_H_
#define MP_OSDEP_THREADS_H_
#include <pthread.h>
struct timespec mpthread_get_deadline(double timeout);
int mpthread_cond_timed_wait(pthread_cond_t *cond, pthread_mutex_t *mutex,
double timeout);
int mpthread_mutex_init_recursive(pthread_mutex_t *mutex);
#endif