1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//! \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()
    {
      EnterCriticalSection(&mCriticalSection);
    }
    virtual void unlock()
    {
      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()
    {
      pthread_mutex_lock(&mMutex);
    }
    virtual void unlock()
    {
      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;
}