@@ -37,35 +37,34 @@ class AtomicCounter
37
37
public:
38
38
typedef IPTR counter_type;
39
39
40
- explicit AtomicCounter (counter_type value = 0 )
40
+ explicit AtomicCounter (counter_type value = 0 ) noexcept
41
41
: counter(value)
42
42
{
43
- static_assert (sizeof (counter_type) == sizeof (counter), " Internal and external counter sizes need to match" );
44
43
}
45
44
46
45
~AtomicCounter ()
47
46
{
48
47
}
49
48
50
- counter_type value () const { return counter.load (std::memory_order_acquire); }
49
+ counter_type value () const noexcept { return counter.load (std::memory_order_acquire); }
51
50
52
- counter_type exchangeAdd (counter_type value)
51
+ counter_type exchangeAdd (counter_type value) noexcept
53
52
{
54
53
return counter.fetch_add (value);
55
54
}
56
55
57
- void setValue (counter_type val)
56
+ void setValue (counter_type val) noexcept
58
57
{
59
58
counter.store (val, std::memory_order_release);
60
59
}
61
60
62
- bool compareExchange (counter_type oldVal, counter_type newVal)
61
+ bool compareExchange (counter_type oldVal, counter_type newVal) noexcept
63
62
{
64
63
return counter.compare_exchange_strong (oldVal, newVal);
65
64
}
66
65
67
66
// returns old value
68
- counter_type exchangeBitAnd (counter_type val)
67
+ counter_type exchangeBitAnd (counter_type val) noexcept
69
68
{
70
69
while (true )
71
70
{
@@ -76,7 +75,7 @@ class AtomicCounter
76
75
}
77
76
78
77
// returns old value
79
- counter_type exchangeBitOr (counter_type val)
78
+ counter_type exchangeBitOr (counter_type val) noexcept
80
79
{
81
80
while (true )
82
81
{
@@ -87,7 +86,7 @@ class AtomicCounter
87
86
}
88
87
89
88
// returns old value
90
- counter_type exchangeGreater (counter_type val)
89
+ counter_type exchangeGreater (counter_type val) noexcept
91
90
{
92
91
while (true )
93
92
{
@@ -102,7 +101,7 @@ class AtomicCounter
102
101
}
103
102
104
103
// returns old value
105
- counter_type exchangeLower (counter_type val)
104
+ counter_type exchangeLower (counter_type val) noexcept
106
105
{
107
106
while (true )
108
107
{
@@ -116,50 +115,52 @@ class AtomicCounter
116
115
}
117
116
}
118
117
119
- void operator &=(counter_type val)
118
+ void operator &=(counter_type val) noexcept
120
119
{
121
120
counter &= val;
122
121
}
123
122
124
- void operator |=(counter_type val)
123
+ void operator |=(counter_type val) noexcept
125
124
{
126
125
counter |= val;
127
126
}
128
127
129
128
// returns new value !
130
- counter_type operator ++()
129
+ counter_type operator ++() noexcept
131
130
{
132
131
return counter++ + 1 ;
133
132
}
134
133
135
134
// returns new value !
136
- counter_type operator --()
135
+ counter_type operator --() noexcept
137
136
{
138
137
return counter-- - 1 ;
139
138
}
140
139
141
- inline operator counter_type () const
140
+ inline operator counter_type () const noexcept
142
141
{
143
142
return value ();
144
143
}
145
144
146
- inline void operator =(counter_type val)
145
+ inline void operator =(counter_type val) noexcept
147
146
{
148
147
setValue (val);
149
148
}
150
149
151
- inline counter_type operator +=(counter_type val)
150
+ inline counter_type operator +=(counter_type val) noexcept
152
151
{
153
152
return exchangeAdd (val) + val;
154
153
}
155
154
156
- inline counter_type operator -=(counter_type val)
155
+ inline counter_type operator -=(counter_type val) noexcept
157
156
{
158
157
return exchangeAdd (-val) - val;
159
158
}
160
159
161
160
private:
162
161
std::atomic<counter_type> counter;
162
+
163
+ static_assert (sizeof (counter_type) == sizeof (counter), " Internal and external counter sizes need to match" );
163
164
};
164
165
165
166
} // namespace Firebird
0 commit comments