SST/macro
thread_safe_int.h
Go to the documentation of this file.
1 #ifndef THREAD_SAFE_INT_H
2 #define THREAD_SAFE_INT_H
3 
5 #include <cstring>
6 
7 namespace sstmac {
8 
10  public lockable
11 {
12 };
13 
14 template <class Integer>
17 {
18 
19  public:
20  template <class Y>
21  thread_safe_int_t(const Y& y) :
22  value_(y)
23  {
24  }
25 
26  template <class Y>
27  Integer& operator=(const Y& y){
28  value_ = y;
29  return value_;
30  }
31 
32  Integer
34  lock();
35  ++value_;
36  Integer tmp = value_;
37  unlock();
38  return tmp;
39  }
40 
41  Integer
42  operator++(int i){
43  Integer tmp(value_);
44  lock();
45  value_++;
46  unlock();
47  return tmp;
48  }
49 
50  operator Integer(){
51  return value_;
52  }
53 
54  protected:
55  Integer value_;
56 
57 };
58 
63 
64 }
65 
66 #endif // THREAD_SAFE_INT_H
thread_safe_int_t< int > thread_safe_int
Integer & operator=(const Y &y)
thread_safe_int_t< long > thread_safe_long
SUMI = Simulator unified messagine interface It is also the name for a solid ink in Japanese - i...
thread_safe_int_t< long long > thread_safe_long_long
thread_safe_int_t< size_t > thread_safe_size_t