Cantera
2.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
include
cantera
base
ct_thread.h
Go to the documentation of this file.
1
/*!
2
* @file ct_thread.h
3
* Header file containing utilities used to ensure thread safety.
4
*/
5
6
#ifndef CT_THREAD_H
7
#define CT_THREAD_H
8
9
#include "config.h"
10
11
#ifdef THREAD_SAFE_CANTERA
12
#include <boost/shared_ptr.hpp>
13
#include <boost/thread/mutex.hpp>
14
15
#endif
16
17
namespace
Cantera {
18
19
#ifdef THREAD_SAFE_CANTERA
20
21
#if defined(BOOST_HAS_WINTHREADS)
22
typedef
unsigned
int
cthreadId_t;
23
#elif defined(BOOST_HAS_PTHREADS)
24
typedef
pthread_t cthreadId_t;
25
#endif
26
27
class
thread_equal
28
{
29
public
:
30
bool
operator()(cthreadId_t L, cthreadId_t R) {
31
#if defined(BOOST_HAS_WINTHREADS)
32
return
L == R;
33
#elif defined(BOOST_HAS_PTHREADS)
34
return
pthread_equal(L, R);
35
#endif
36
}
37
};
38
39
typedef
boost::mutex mutex_t;
40
typedef
boost::mutex::scoped_lock ScopedLock;
41
42
#else
43
typedef
int
mutex_t;
44
45
class
ScopedLock {
46
public
:
47
explicit
ScopedLock(
const
int
m) : m_(m) {}
48
private
:
49
int
m_;
50
};
51
52
#endif // THREAD_SAFE_CANTERA
53
54
}
55
56
#endif
Generated by
1.8.2