29 #ifndef AVCODEC_W32PTHREADS_H
30 #define AVCODEC_W32PTHREADS_H
38 #define WIN32_LEAN_AND_MEAN
47 void *(*func)(
void*
arg);
78 void *(*start_routine)(
void*),
void *arg)
80 thread->
func = start_routine;
89 DWORD ret = WaitForSingleObject(thread.
handle, INFINITE);
90 if (ret != WAIT_OBJECT_0)
93 *value_ptr = thread.
ret;
94 CloseHandle(thread.
handle);
99 InitializeCriticalSection(m);
104 DeleteCriticalSection(m);
109 EnterCriticalSection(m);
114 LeaveCriticalSection(m);
141 cond->
ptr = win32_cond;
174 if (cond_broadcast) {
175 cond_broadcast(cond);
192 WaitForSingleObject(win32_cond->
waiters_done, INFINITE);
205 cond_wait(cond, mutex, INFINITE);
218 WaitForSingleObject(win32_cond->
semaphore, INFINITE);
250 WaitForSingleObject(win32_cond->
waiters_done, INFINITE);
259 HANDLE kernel_dll = GetModuleHandle(TEXT(
"kernel32.dll"));
262 (
void*)GetProcAddress(kernel_dll,
"InitializeConditionVariable");
264 (
void*)GetProcAddress(kernel_dll,
"WakeAllConditionVariable");
266 (
void*)GetProcAddress(kernel_dll,
"WakeConditionVariable");
268 (
void*)GetProcAddress(kernel_dll,
"SleepConditionVariableCS");
volatile int is_broadcast
static int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
struct win32_cond_t win32_cond_t
static void pthread_join(pthread_t thread, void **value_ptr)
memory handling functions
volatile int waiter_count
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static pthread_mutex_t DWORD milliseconds
static void pthread_cond_init(pthread_cond_t *cond, const void *unused_attr)
CRITICAL_SECTION pthread_mutex_t
static int pthread_create(pthread_t *thread, const void *unused_attr, void *(*start_routine)(void *), void *arg)
static void pthread_cond_signal(pthread_cond_t *cond)
static int pthread_mutex_init(pthread_mutex_t *m, void *attr)
void *(* func)(void *arg)
static int pthread_mutex_unlock(pthread_mutex_t *m)
common internal API header
static int pthread_mutex_destroy(pthread_mutex_t *m)
static pthread_mutex_t * mutex
pthread_mutex_t mtx_broadcast
#define attribute_align_arg
static int pthread_mutex_lock(pthread_mutex_t *m)
static void pthread_cond_destroy(pthread_cond_t *cond)
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
struct pthread_t pthread_t
static void pthread_cond_broadcast(pthread_cond_t *cond)
static void w32thread_init(void)
pthread_mutex_t mtx_waiter_count
static BOOL(WINAPI *cond_wait)(pthread_cond_t *cond
struct pthread_cond_t pthread_cond_t
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static unsigned __stdcall attribute_align_arg win32thread_worker(void *arg)