Menu

[r1519]: / cppdb / trunk / mutex.cpp  Maximize  Restore  History

Download this file

41 lines (34 with data), 593 Bytes

 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
#define CPPDB_SOURCE
#include "mutex.h"
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32)
#define USE_WINAPI
#endif
#ifdef USE_WINAPI
#error implement me
#else
#include <pthread.h>
#ifdef impl_
#undef impl_
#endif
#define impl_ (*(pthread_mutex_t **)&mutex_impl_)
#endif
namespace cppdb {
mutex::mutex() : mutex_impl_(0)
{
impl_ = new pthread_mutex_t();
pthread_mutex_init(impl_,0);
}
mutex::~mutex()
{
pthread_mutex_destroy(impl_);
delete impl_;
}
void mutex::lock()
{
pthread_mutex_lock(impl_);
}
void mutex::unlock()
{
pthread_mutex_unlock(impl_);
}
}