blob: aa00300dec549f3f19a0f2929a3bd9206f1f3052 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
/******************************************************
The interface to the operating system synchronization primitives.
(c) 1995 Innobase Oy
Created 9/6/1995 Heikki Tuuri
*******************************************************/
#ifdef __WIN__
#include <winbase.h>
#endif
#ifndef _WIN32
/**************************************************************
Acquires ownership of a fast mutex. */
UNIV_INLINE
ulint
os_fast_mutex_trylock(
/*==================*/
/* out: 0 if success, != 0 if
was reserved by another
thread */
os_fast_mutex_t* fast_mutex) /* in: mutex to acquire */
{
#ifdef __WIN__
int ret;
/* TODO: TryEnterCriticalSection is probably not found from
NT versions < 4! */
ret = TryEnterCriticalSection(fast_mutex);
if (ret) {
return(0);
}
return(1);
#else
return((ulint) pthread_mutex_trylock(fast_mutex));
#endif
}
#endif
|