C:/fscan/HTTPCore/Threading.cpp

Go to the documentation of this file.
00001 
00005 #include "Build.h"
00006 #include "Threading.h"
00007 
00008 #include <stdio.h>
00009 #include <string.h>
00010 #ifdef __WIN32__RELEASE__
00011  #include <windows.h>
00012 #else
00013  #include <unistd.h>
00014  #include <pthread.h>  //pthread
00015 #endif
00016 
00017 /******************************************************************************/
00019 
00023 /******************************************************************************/
00024 
00025 void LockMutex(void *mutex)
00026 {
00027 if (mutex) {
00028         
00029 
00030 #ifdef __WIN32__RELEASE__
00031    EnterCriticalSection((CRITICAL_SECTION*)mutex);
00032 #else
00033    pthread_mutex_lock ((pthread_mutex_t*)mutex);
00034 #endif
00035 }
00036 }
00037 /******************************************************************************/
00039 
00043 /******************************************************************************/
00044 void UnLockMutex(void *mutex)
00045 {
00046 if (mutex) {
00047         
00048 
00049 #ifdef __WIN32__RELEASE__
00050    LeaveCriticalSection((CRITICAL_SECTION*)mutex);
00051 #else
00052    pthread_mutex_unlock ((pthread_mutex_t*)mutex);
00053 #endif
00054         }
00055 }
00056 /******************************************************************************/
00058 
00062 /******************************************************************************/
00063 void InitMutex(void *mutex)
00064 {
00065 #ifdef __WIN32__RELEASE__
00066    InitializeCriticalSection((CRITICAL_SECTION*)mutex);
00067 #else
00068    pthread_mutexattr_t mutexattr;
00069    pthread_mutexattr_settype(&mutexattr,PTHREAD_MUTEX_RECURSIVE); // Set the mutex as recursive
00070    pthread_mutex_init((pthread_mutex_t*)mutex, &mutexattr);  // create the mutex with the attributes set
00071    pthread_mutexattr_destroy(&mutexattr);
00072 #endif
00073 }
00074 /******************************************************************************/
00076 
00080 /******************************************************************************/
00081 void DeleteMutex(void *mutex)
00082 {
00083 #ifdef __WIN32__RELEASE__
00084 DeleteCriticalSection((CRITICAL_SECTION*)mutex);
00085 #else
00086 pthread_mutex_destroy ((pthread_mutex_t*)mutex);
00087 #endif
00088 
00089 }
00090 
00091 /******************************************************************************/
00092 

Generated on Sun Jan 18 00:32:04 2009 for Fast HTTP Vulnerability Scanner by  doxygen 1.5.4