109 typedef NOT_LP64(uint16_t) LP64_ONLY(uint32_t) idx_t;
110
111 // The first free element after the last one pushed (mod N).
112 volatile uint _bottom;
113
114 enum { MOD_N_MASK = N - 1 };
115
116 class Age {
117 public:
118 Age(size_t data = 0) { _data = data; }
119 Age(const Age& age) { _data = age._data; }
120 Age(idx_t top, idx_t tag) { _fields._top = top; _fields._tag = tag; }
121
122 Age get() const volatile { return _data; }
123 void set(Age age) volatile { _data = age._data; }
124
125 idx_t top() const volatile { return _fields._top; }
126 idx_t tag() const volatile { return _fields._tag; }
127
128 // Increment top; if it wraps, increment tag also.
129 void increment() {
130 _fields._top = increment_index(_fields._top);
131 if (_fields._top == 0) ++_fields._tag;
132 }
133
134 Age cmpxchg(const Age new_age, const Age old_age) volatile;
135
136 bool operator ==(const Age& other) const { return _data == other._data; }
137
138 private:
139 struct fields {
140 idx_t _top;
141 idx_t _tag;
142 };
143 union {
144 size_t _data;
145 fields _fields;
146 };
147 };
148
149 volatile Age _age;
|
109 typedef NOT_LP64(uint16_t) LP64_ONLY(uint32_t) idx_t;
110
111 // The first free element after the last one pushed (mod N).
112 volatile uint _bottom;
113
114 enum { MOD_N_MASK = N - 1 };
115
116 class Age {
117 public:
118 Age(size_t data = 0) { _data = data; }
119 Age(const Age& age) { _data = age._data; }
120 Age(idx_t top, idx_t tag) { _fields._top = top; _fields._tag = tag; }
121
122 Age get() const volatile { return _data; }
123 void set(Age age) volatile { _data = age._data; }
124
125 idx_t top() const volatile { return _fields._top; }
126 idx_t tag() const volatile { return _fields._tag; }
127
128 // Increment top; if it wraps, increment tag also.
129 void increment() volatile {
130 _fields._top = increment_index(_fields._top);
131 if (_fields._top == 0) ++_fields._tag;
132 }
133
134 Age cmpxchg(const Age new_age, const Age old_age) volatile;
135
136 bool operator ==(const Age& other) const { return _data == other._data; }
137
138 private:
139 struct fields {
140 idx_t _top;
141 idx_t _tag;
142 };
143 union {
144 size_t _data;
145 fields _fields;
146 };
147 };
148
149 volatile Age _age;
|