//! \file CubitConcurrentApi.cpp
#include "CubitConcurrentApi.h"
#ifdef _WIN32
#include <windows.h>
#else
#include <pthread.h>
#endif
#ifdef _WIN32
// struct for working with mutexes
class RealMutex : public CubitConcurrent::Mutex
{
public:
RealMutex()
{
InitializeCriticalSection(&mCriticalSection);
}
~RealMutex()
{
DeleteCriticalSection(&mCriticalSection);
}
virtual void lock()<--- Function in derived class
{
EnterCriticalSection(&mCriticalSection);
}
virtual void unlock()<--- Function in derived class
{
LeaveCriticalSection(&mCriticalSection);
}
protected:
CRITICAL_SECTION mCriticalSection;
};
#else
// struct for working with mutexes
class RealMutex : public CubitConcurrent::Mutex
{
public:
RealMutex()
{
pthread_mutex_init(&mMutex, NULL);
}
~RealMutex()
{
pthread_mutex_destroy(&mMutex);
}
virtual void lock()<--- Function in derived class
{
pthread_mutex_lock(&mMutex);
}
virtual void unlock()<--- Function in derived class
{
pthread_mutex_unlock(&mMutex);
}
protected:
pthread_mutex_t mMutex;
};
#endif
CubitConcurrent *CubitConcurrent::mInstance = 0;
CubitConcurrent::CubitConcurrent()
{
}
CubitConcurrent::~CubitConcurrent()
{
}
const char* CubitConcurrent::get_base_type() const<--- The function 'get_base_type' is never used.
{
return "ConcurrentApi";
}
CubitConcurrent::Mutex* CubitConcurrent::create_mutex()<--- The function 'create_mutex' is never used.
{
return new RealMutex;
}
void CubitConcurrent::destroy_mutex(CubitConcurrent::Mutex* m)<--- The function 'destroy_mutex' is never used.
{
delete m;
}