Menu

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

Download this file

40 lines (32 with data), 570 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
#define CPPDB_SOURCE
#include "mutex.h"
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32)
// TODO
#error implement me
#else // POSIX
#include <pthread.h>
#ifdef impl_
#undef impl_
#endif
#define impl_ ((pthread_mutex_t *)mutex_impl_)
namespace cppdb {
mutex::mutex() : mutex_impl_(0)
{
mutex_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_);
}
}
#endif