Home | History | Annotate | Download | only in Python

Lines Matching defs:mutex

20 InitializeNonRecursiveMutex(PNRMUTEX mutex)
22 mutex->owned = -1 ; /* No threads have entered NonRecursiveMutex */
23 mutex->thread_id = 0 ;
24 mutex->hevent = CreateEvent(NULL, FALSE, FALSE, NULL) ;
25 return mutex->hevent != NULL ; /* TRUE if the mutex is created */
29 DeleteNonRecursiveMutex(PNRMUTEX mutex)
32 CloseHandle(mutex->hevent) ;
33 mutex->hevent = NULL ; /* Just in case */
37 EnterNonRecursiveMutex(PNRMUTEX mutex, BOOL wait)
42 /* InterlockedIncrement(&mutex->owned) == 0 means that no thread currently owns the mutex */
45 if (InterlockedCompareExchange(&mutex->owned, 0, -1) != -1)
50 ret = InterlockedIncrement(&mutex->owned) ?
51 /* Some thread owns the mutex, let's wait... */
52 WaitForSingleObject(mutex->hevent, INFINITE) : WAIT_OBJECT_0 ;
54 mutex->thread_id = GetCurrentThreadId() ; /* We own it */
59 LeaveNonRecursiveMutex(PNRMUTEX mutex)
61 /* We don't own the mutex */
62 mutex->thread_id = 0 ;
64 InterlockedDecrement(&mutex->owned) < 0 ||
65 SetEvent(mutex->hevent) ; /* Other threads are waiting, wake one on them up */
71 PNRMUTEX mutex = (PNRMUTEX)malloc(sizeof(NRMUTEX)) ;
72 if (mutex && !InitializeNonRecursiveMutex(mutex))
74 free(mutex) ;
75 mutex = NULL ;
77 return mutex ;
81 FreeNonRecursiveMutex(PNRMUTEX mutex)
83 if (mutex)
85 DeleteNonRecursiveMutex(mutex) ;
86 free(mutex) ;
208 * I [Dag] tried to implement it with mutex but I could find a way to