96 INLINE
bool UpdateSeq::
97 operator == (
const UpdateSeq &other)
const {
104 INLINE
bool UpdateSeq::
105 operator != (
const UpdateSeq &other)
const {
112 INLINE
bool UpdateSeq::
113 operator < (
const UpdateSeq &other)
const {
120 INLINE
bool UpdateSeq::
121 operator <= (
const UpdateSeq &other)
const {
128 INLINE
bool UpdateSeq::
129 operator > (
const UpdateSeq &other)
const {
130 return (other < (*
this));
136 INLINE
bool UpdateSeq::
137 operator >= (
const UpdateSeq &other)
const {
138 return (other <= (*
this));
147 AtomicAdjust::Integer new_seq = old_seq + 1;
148 if (priv_is_special(new_seq)) {
151 new_seq = (AtomicAdjust::Integer)SC_old + 1;
156 while (result != old_seq) {
159 new_seq = old_seq + 1;
160 if (priv_is_special(new_seq)) {
163 new_seq = (AtomicAdjust::Integer)SC_old + 1;
169 #endif // HAVE_THREADS 180 AtomicAdjust::Integer new_seq = old_seq + 1;
181 if (priv_is_special(new_seq)) {
184 new_seq = (AtomicAdjust::Integer)SC_old + 1;
189 while (result != old_seq) {
192 new_seq = old_seq + 1;
193 if (priv_is_special(new_seq)) {
196 new_seq = (AtomicAdjust::Integer)SC_old + 1;
202 #endif // HAVE_THREADS 213 INLINE AtomicAdjust::Integer UpdateSeq::
221 INLINE
void UpdateSeq::
222 output(std::ostream &out)
const {
225 case (AtomicAdjust::Integer)SC_initial:
229 case (AtomicAdjust::Integer)SC_old:
233 case (AtomicAdjust::Integer)SC_fresh:
245 INLINE
bool UpdateSeq::
246 priv_is_special(AtomicAdjust::Integer seq) {
248 return (((
unsigned int)seq + 1) <= 2);
254 INLINE
bool UpdateSeq::
255 priv_lt(AtomicAdjust::Integer a, AtomicAdjust::Integer b) {
262 (priv_is_special(a) || priv_is_special(b)) ? ((
unsigned int)a < (
unsigned int)b) :
263 ((
signed int)(a - b) < 0);
269 INLINE
bool UpdateSeq::
270 priv_le(AtomicAdjust::Integer a, AtomicAdjust::Integer b) {
271 return (a == b) || priv_lt(a, b);
274 INLINE std::ostream &operator << (std::ostream &out,
const UpdateSeq &value) {
void clear()
Resets the UpdateSeq to the 'initial' 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.
A trivial implementation for atomic adjustments for systems that don't require multiprogramming,...
constexpr UpdateSeq()
Creates an UpdateSeq in the 'initial' state.
static Integer get(const Integer &var)
Atomically retrieves the snapshot value of the indicated variable.
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.
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.