29 #ifndef AVCODEC_W32PTHREADS_H
30 #define AVCODEC_W32PTHREADS_H
38 #define WIN32_LEAN_AND_MEAN
44 void *(*func)(
void* arg);
75 void *(*start_routine)(
void*),
void *arg)
77 thread->
func = start_routine;
86 DWORD ret = WaitForSingleObject(thread.
handle, INFINITE);
87 if (ret != WAIT_OBJECT_0)
90 *value_ptr = thread.
ret;
91 CloseHandle(thread.
handle);
96 InitializeCriticalSection(m);
101 DeleteCriticalSection(m);
106 EnterCriticalSection(m);
111 LeaveCriticalSection(m);
138 cond->
ptr = win32_cond;
171 if (cond_broadcast) {
172 cond_broadcast(cond);
189 WaitForSingleObject(win32_cond->
waiters_done, INFINITE);
202 cond_wait(cond, mutex, INFINITE);
215 WaitForSingleObject(win32_cond->
semaphore, INFINITE);
247 WaitForSingleObject(win32_cond->
waiters_done, INFINITE);
256 HANDLE kernel_dll = GetModuleHandle(TEXT(
"kernel32.dll"));
259 (
void*)GetProcAddress(kernel_dll,
"InitializeConditionVariable");
261 (
void*)GetProcAddress(kernel_dll,
"WakeAllConditionVariable");
263 (
void*)GetProcAddress(kernel_dll,
"WakeConditionVariable");
265 (
void*)GetProcAddress(kernel_dll,
"SleepConditionVariableCS");
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
volatile int is_broadcast
static void pthread_join(pthread_t thread, void **value_ptr)
static void pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
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)
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)
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
static unsigned __stdcall attribute_align_arg win32thread_worker(void *arg)