Changeset a6b48f6 for libcfa/src/collections
- Timestamp:
- Dec 24, 2024, 10:52:13 AM (4 weeks ago)
- Branches:
- master
- Children:
- 2853d6f, 5db580e
- Parents:
- 4f4ae60
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/collections/lockfree.hfa
r4f4ae60 ra6b48f6 6 6 #include <bits/defs.hfa> 7 7 8 forall( T & ) {8 forall( T & ) { 9 9 //------------------------------------------------------------ 10 10 // Queue based on the MCS lock … … 200 200 forall( T & ) 201 201 struct LinkData { 202 T * volatile top; // pointer to stack top203 uintptr_t count; // count each push202 T * volatile top; // pointer to stack top 203 uintptr_t count; // count each push 204 204 }; 205 205 … … 215 215 }; // Link 216 216 217 forall( T | sized(T)| { Link(T) * ?`next( T * ); } ) {217 forall( T /*| sized(T)*/ | { Link(T) * ?`next( T * ); } ) { 218 218 struct StackLF { 219 219 Link(T) stack; … … 235 235 Link(T) t @= stack; // atomic assignment unnecessary, or use CAA 236 236 for () { // busy wait 237 if ( t.data.top == 0p ) return 0p; 237 if ( t.data.top == 0p ) return 0p; // empty stack ? 238 238 Link(T) * next = ( t.data.top )`next; 239 239 if ( __atomic_compare_exchange_n( &stack.atom, &t.atom, (Link(T))@{ (LinkData(T))@{ next->data.top, t.data.count } }.atom, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ) ) return t.data.top; // attempt to update top node
Note: See TracChangeset
for help on using the changeset viewer.