- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# Y:/msp/devkits/temp_geotrans/master/geotrans3.1/CCS/src/dtcc/CoordinateSystems/threads/CCSThreadMutex.cpp

Go to the documentation of this file.

    00001 // CLASSIFICATION: UNCLASSIFIED
    00002
    00003 #ifdef WIN32
    00004 #  include <windows.h>
    00005 #endif
    00006
    00007 #include "CCSThreadMutex.h"
    00008
    00009 using MSP::CCSThreadMutex;
    00010
    00011 CCSThreadMutex::CCSThreadMutex()
    00012 {
    00013 #ifdef WIN32
    00014    mutex = (void*)CreateMutex(NULL,FALSE,NULL);
    00015 #else
    00016    // force a recursive mutex to match windows implementation.
    00017    pthread_mutexattr_t attr;
    00018    pthread_mutexattr_init(&attr);
    00019    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
    00020    pthread_mutex_init(&mutex, &attr);
    00021 #endif
    00022 }
    00023
    00024 CCSThreadMutex::~CCSThreadMutex()
    00025 {
    00026 #ifdef WIN32
    00027    CloseHandle((HANDLE)mutex);
    00028 #else
    00029    // force a recursive mutex to match windows implementation.
    00030    pthread_mutex_destroy(&mutex);
    00031 #endif
    00032 }
    00033 void
    00034 CCSThreadMutex::lock() const
    00035 {
    00036 #ifdef WIN32
    00037    WaitForSingleObject((HANDLE)mutex, INFINITE);
    00038 #else
    00039    // force a recursive mutex to match windows implementation.
    00040    pthread_mutex_lock(&mutex);
    00041 #endif
    00042 }
    00043
    00044
    00045 void
    00046 CCSThreadMutex::unlock() const
    00047 {
    00048 #ifdef WIN32
    00049    ReleaseMutex((HANDLE)mutex);
    00050 #else
    00051    // force a recursive mutex to match windows implementation.
    00052    pthread_mutex_unlock(&mutex);
    00053 #endif
    00054 }
    00055
    00056 // CLASSIFICATION: UNCLASSIFIED