Lines Matching refs:mutex
20 InitializeNonRecursiveMutex(PNRMUTEX mutex) in InitializeNonRecursiveMutex() argument
22 mutex->owned = -1 ; /* No threads have entered NonRecursiveMutex */ in InitializeNonRecursiveMutex()
23 mutex->thread_id = 0 ; in InitializeNonRecursiveMutex()
24 mutex->hevent = CreateEvent(NULL, FALSE, FALSE, NULL) ; in InitializeNonRecursiveMutex()
25 return mutex->hevent != NULL ; /* TRUE if the mutex is created */ in InitializeNonRecursiveMutex()
29 DeleteNonRecursiveMutex(PNRMUTEX mutex) in DeleteNonRecursiveMutex() argument
32 CloseHandle(mutex->hevent) ; in DeleteNonRecursiveMutex()
33 mutex->hevent = NULL ; /* Just in case */ in DeleteNonRecursiveMutex()
37 EnterNonRecursiveMutex(PNRMUTEX mutex, BOOL wait) in EnterNonRecursiveMutex() argument
45 if (InterlockedCompareExchange(&mutex->owned, 0, -1) != -1) in EnterNonRecursiveMutex()
50 ret = InterlockedIncrement(&mutex->owned) ? in EnterNonRecursiveMutex()
52 WaitForSingleObject(mutex->hevent, INFINITE) : WAIT_OBJECT_0 ; in EnterNonRecursiveMutex()
54 mutex->thread_id = GetCurrentThreadId() ; /* We own it */ in EnterNonRecursiveMutex()
59 LeaveNonRecursiveMutex(PNRMUTEX mutex) in LeaveNonRecursiveMutex() argument
62 mutex->thread_id = 0 ; in LeaveNonRecursiveMutex()
64 InterlockedDecrement(&mutex->owned) < 0 || in LeaveNonRecursiveMutex()
65 SetEvent(mutex->hevent) ; /* Other threads are waiting, wake one on them up */ in LeaveNonRecursiveMutex()
71 PNRMUTEX mutex = (PNRMUTEX)malloc(sizeof(NRMUTEX)) ; in AllocNonRecursiveMutex() local
72 if (mutex && !InitializeNonRecursiveMutex(mutex)) in AllocNonRecursiveMutex()
74 free(mutex) ; in AllocNonRecursiveMutex()
75 mutex = NULL ; in AllocNonRecursiveMutex()
77 return mutex ; in AllocNonRecursiveMutex()
81 FreeNonRecursiveMutex(PNRMUTEX mutex) in FreeNonRecursiveMutex() argument
83 if (mutex) in FreeNonRecursiveMutex()
85 DeleteNonRecursiveMutex(mutex) ; in FreeNonRecursiveMutex()
86 free(mutex) ; in FreeNonRecursiveMutex()