FreeBASIC  0.91.0
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 
7 {
8  FBMUTEX *mutex = (FBMUTEX *)malloc( sizeof( FBMUTEX ) );
9  if( !mutex )
10  return NULL;
11 
12  pthread_mutex_init( &mutex->id, NULL );
13 
14  return mutex;
15 }
16 
18 {
19  if( mutex ) {
20  pthread_mutex_destroy( &mutex->id );
21  free( (void *)mutex );
22  }
23 }
24 
26 {
27  if( mutex ) {
28  pthread_mutex_lock( &mutex->id );
29  }
30 }
31 
33 {
34  if( mutex ) {
35  pthread_mutex_unlock( &mutex->id );
36  }
37 }