FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
thread_mutex.c
Go to the documentation of this file.
1
/* mutex handling routines */
2
3
#include "../fb.h"
4
#include "../fb_private_thread.h"
5
6
FBCALL
FBMUTEX
*
fb_MutexCreate
(
void
)
7
{
8
FBMUTEX
*
mutex
= (
FBMUTEX
*)malloc(
sizeof
(
FBMUTEX
) );
9
if
( !mutex )
10
return
NULL
;
11
12
mutex->id = CreateSemaphore(
NULL
, 1, 1,
NULL
);
13
14
return
mutex
;
15
}
16
17
FBCALL
void
fb_MutexDestroy
(
FBMUTEX
*
mutex
)
18
{
19
if
( mutex ) {
20
CloseHandle( mutex->id );
21
free( (
void
*)mutex );
22
}
23
}
24
25
FBCALL
void
fb_MutexLock
(
FBMUTEX
*
mutex
)
26
{
27
if
( mutex ) {
28
WaitForSingleObject( mutex->id, INFINITE );
29
}
30
}
31
32
FBCALL
void
fb_MutexUnlock
(
FBMUTEX
*
mutex
)
33
{
34
if
( mutex ) {
35
ReleaseSemaphore( mutex->id, 1,
NULL
);
36
}
37
}
rtlib
win32
thread_mutex.c
Generated on Thu Jan 23 2014 19:40:10 for FreeBASIC by
1.8.4