Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

GMutex.h

Go to the documentation of this file.
00001 //========================================================================
00002 //
00003 // GMutex.h
00004 //
00005 // Portable mutex macros.
00006 //
00007 // Copyright 2002-2003 Glyph & Cog, LLC
00008 //
00009 //========================================================================
00010 
00011 #ifndef GMUTEX_H
00012 #define GMUTEX_H
00013 
00014 // Usage:
00015 //
00016 // GMutex m;
00017 // gInitMutex(&m);
00018 // ...
00019 // gLockMutex(&m);
00020 //   ... critical section ...
00021 // gUnlockMutex(&m);
00022 // ...
00023 // gDestroyMutex(&m);
00024 
00025 #ifdef WIN32
00026 
00027 #include <windows.h>
00028 
00029 typedef CRITICAL_SECTION GMutex;
00030 
00031 #define gInitMutex(m) InitializeCriticalSection(m)
00032 #define gDestroyMutex(m) DeleteCriticalSection(m)
00033 #define gLockMutex(m) EnterCriticalSection(m)
00034 #define gUnlockMutex(m) LeaveCriticalSection(m)
00035 
00036 #else // assume pthreads
00037 
00038 #include <pthread.h>
00039 
00040 typedef pthread_mutex_t GMutex;
00041 
00042 #define gInitMutex(m) pthread_mutex_init(m, NULL)
00043 #define gDestroyMutex(m) pthread_mutex_destroy(m)
00044 #define gLockMutex(m) pthread_mutex_lock(m)
00045 #define gUnlockMutex(m) pthread_mutex_unlock(m)
00046 
00047 #endif
00048 
00049 #endif

Generated on Wed Nov 3 12:58:57 2004 for Lemur Toolkit by doxygen1.2.18