23 _seq = (
unsigned int)SC_initial;
44 result._seq = (
unsigned int)SC_old;
56 result._seq = (
unsigned int)SC_fresh;
140 INLINE
bool UpdateSeq::
141 operator == (
const UpdateSeq &other)
const {
150 INLINE
bool UpdateSeq::
151 operator != (
const UpdateSeq &other)
const {
160 INLINE
bool UpdateSeq::
161 operator < (
const UpdateSeq &other)
const {
170 INLINE
bool UpdateSeq::
171 operator <= (
const UpdateSeq &other)
const {
180 INLINE
bool UpdateSeq::
181 operator > (
const UpdateSeq &other)
const {
182 return (other < (*
this));
190 INLINE
bool UpdateSeq::
191 operator >= (
const UpdateSeq &other)
const {
192 return (other <= (*
this));
203 AtomicAdjust::Integer new_seq = old_seq + 1;
204 if (priv_is_special(new_seq)) {
207 new_seq = (AtomicAdjust::Integer)SC_old + 1;
212 while (result != old_seq) {
215 new_seq = old_seq + 1;
216 if (priv_is_special(new_seq)) {
219 new_seq = (AtomicAdjust::Integer)SC_old + 1;
225 #endif // HAVE_THREADS 238 AtomicAdjust::Integer new_seq = old_seq + 1;
239 if (priv_is_special(new_seq)) {
242 new_seq = (AtomicAdjust::Integer)SC_old + 1;
247 while (result != old_seq) {
250 new_seq = old_seq + 1;
251 if (priv_is_special(new_seq)) {
254 new_seq = (AtomicAdjust::Integer)SC_old + 1;
260 #endif // HAVE_THREADS 283 INLINE
void UpdateSeq::
284 output(ostream &out)
const {
287 case (AtomicAdjust::Integer)SC_initial:
291 case (AtomicAdjust::Integer)SC_old:
295 case (AtomicAdjust::Integer)SC_fresh:
309 INLINE
bool UpdateSeq::
310 priv_is_special(AtomicAdjust::Integer seq) {
312 return (((
unsigned int)seq + 1) <= 2);
320 INLINE
bool UpdateSeq::
321 priv_lt(AtomicAdjust::Integer a, AtomicAdjust::Integer b) {
328 (priv_is_special(a) || priv_is_special(b)) ? ((
unsigned int)a < (
unsigned int)b) :
329 ((
signed int)(a - b) < 0);
337 INLINE
bool UpdateSeq::
338 priv_le(AtomicAdjust::Integer a, AtomicAdjust::Integer b) {
339 return (a == b) || priv_lt(a, b);
342 INLINE ostream &operator << (ostream &out,
const UpdateSeq &value) {
void clear()
Resets the UpdateSeq to the 'initial' state.
static UpdateSeq fresh()
Returns an UpdateSeq in the 'fresh' state.
bool is_special() const
Returns true if the UpdateSeq is in any special states, i.e.
bool is_initial() const
Returns true if the UpdateSeq is in the 'initial' state.
UpdateSeq()
Creates an UpdateSeq in the 'initial' state.
static Integer get(const Integer &var)
Atomically retrieves the snapshot value of the indicated variable.
static UpdateSeq old()
Returns an UpdateSeq in the 'old' state.
bool is_fresh() const
Returns true if the UpdateSeq is in the 'fresh' state.
static Integer set(Integer &var, Integer new_value)
Atomically changes the indicated variable and returns the original value.
AtomicAdjust::Integer get_seq() const
Returns the internal integer value associated with the UpdateSeq.
bool is_old() const
Returns true if the UpdateSeq is in the 'old' state.
This is a sequence number that increments monotonically.
static Integer compare_and_exchange(Integer &mem, Integer old_value, Integer new_value)
Atomic compare and exchange.
static UpdateSeq initial()
Returns an UpdateSeq in the 'initial' state.