summaryrefslogtreecommitdiffstats
path: root/osdep/threads.h
Commit message (Collapse)AuthorAgeFilesLines
* threads: unbreak mpv on builds without assertsKacper Michajłow2023-11-061-1/+1
| | | | | | Also remove duplicated macro. Fixes: #12818 #12820
* threads: remove unused codeKacper Michajłow2023-11-051-8/+0
|
* threads: move pthread debug to threads-posix.hKacper Michajłow2023-11-051-61/+0
| | | | And remove redundant define while at it.
* mp_thread: add win32 implementationKacper Michajłow2023-11-051-0/+6
|
* threads: add new mp_thread abstractionKacper Michajłow2023-11-051-0/+13
| | | | | | This will allow to avoid hacky pthreads symbols/header override. Inspired by pl_thread from libplacebo.
* threads: add support for pthread_mutex_trylockThomas Weißschuh2023-10-201-0/+5
|
* osdep: add a pthread debugging wrapperwm42020-03-181-0/+55
| | | | | | | | | | | | | | | | | | | | Because pthread failures are virtually undebuggable (which sure is pretty strange, given all these heavy instrumentation tools these days). Of course it affects only files which include osdep/threads.h. I'm departing from the usual way to add symbols with config.h and using "#if", and defining it on the compiler command line + "#ifdef" because I don't want to include config.h from a header (which would be necessary in this case) to keep things slightly cleaner. Maybe this is misguided, but still. This would have been easier if mpv defined its own wrappers for all thread functions. But we don't (which to be honest is probably better than e.g. going crazy like VLC and essentially reimplementing everything). This seems to be a good compromise. Since it's off by default and basically a developer tool, the minor undefined behavior (redefining reserved symbols) isn't much of an issue.
* threads: use utility+POSIX functions instead of weird wrapperswm42015-05-111-9/+0
| | | | | | | There is not much of a reason to have these wrappers around. Use POSIX standard functions directly, and use a separate utility function to take care of the timespec calculations. (Course POSIX for using this weird format for time values.)
* Set thread name for debuggingwm42014-10-191-0/+3
| | | | | | | | | | Especially with other components (libavcodec, OSX stuff), the thread list can get quite populated. Setting the thread name helps when debugging. Since this is not portable, we check the OS variants in waf configure. old-configure just gets a special-case for glibc, since doing a full check here would probably be a waste of effort.
* threads: use mpv time for mpthread_cond_timedwait wrapperwm42014-05-181-3/+9
| | | | | | 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.
* threads: fix function namewm42014-04-231-2/+2
| | | | Closer to the corresponding standard function pthread_cond_timedwait.
* dispatch: move into its own source filewm42014-04-231-21/+0
| | | | | | | This was part of osdep/threads.c out of laziness. But it doesn't contain anything OS dependent. Note that the rest of threads.c actually isn't all that OS dependent either (just some minor ifdeffery to work around the lack of clock_gettime() on OSX).
* threads: add a dispatch queue thingwm42014-02-101-0/+21
| | | | | | Makes working with the (still) single-threaded playback thread easier. Might be reusable for other stuff.
* threads: add function to calculate deadline for timed waitswm42014-01-311-0/+2
| | | | | | | | | | | | 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.
* threads: add wrapper for initializing recursive mutexeswm42014-01-311-0/+2
| | | | Damn this overly verbose pthread API.
* stream: split out pthread helper functionwm42013-11-171-0/+9
Also split the function itself into 3.