path: root/
diff options
authorwm4 <wm4@nowhere>2018-05-06 13:00:05 +0200
committerwm4 <wm4@nowhere>2018-05-24 19:56:34 +0200
commit22c002138d8b82a021564ddab447fafd90852e75 (patch)
tree233503a74b229f24bdedfc70b18d29f6354b46ae /
parent383da1bfd59fa77366d5e61612da4da8d4f1cf6c (diff)
misc: add a synchronization helper
This is almost like rendezvous(), except it allows async wakeup, and does not require global state. It will be used by a later commit. struct mp_waiter is intended to be allocated on the stack, and uses an initializer including PTHREAD_MUTEX_INITIALIZER. This is the first case in mpv that it uses PTHREAD_MUTEX_INITIALIZER for stack-allocated mutexes. It seems POSIX still does not allow this formally, but since POSIX is worth less than used toilet paper, I don't really care. Modern OSes use futexes, which means you can make _every_ memory location a lock, and this code tries to make use of it, without using OS specific code. The name of the source file is rather generic, because I intend to dump further small helpers there (or maybe move mp_rendezvous() to it).
Diffstat (limited to '')
1 files changed, 1 insertions, 0 deletions
diff --git a/ b/
index 4b9b60e569..e37eb7e775 100644
--- a/
+++ b/
@@ -323,6 +323,7 @@ def build(ctx):
( "misc/rendezvous.c" ),
( "misc/ring.c" ),
( "misc/thread_pool.c" ),
+ ( "misc/thread_tools.c" ),
## Options
( "options/m_config.c" ),