Changeset 8b58bae for libcfa/src/containers
- Timestamp:
- Jun 24, 2020, 5:00:59 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- c953163
- Parents:
- 9791ab5 (diff), 7f9968ad (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- libcfa/src/containers
- Files:
-
- 2 edited
-
stackLockFree.hfa (modified) (4 diffs)
-
vector.hfa (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/containers/stackLockFree.hfa
r9791ab5 r8b58bae 9 9 // Created On : Wed May 13 20:58:58 2020 10 10 // Last Modified By : Peter A. Buhr 11 // Last Modified On : Mon May 18 13:30:08202012 // Update Count : 5511 // Last Modified On : Sun Jun 14 13:25:09 2020 12 // Update Count : 64 13 13 // 14 14 … … 19 19 forall( dtype T ) 20 20 union Link { 21 struct { // 32/64-bit x 221 struct { // 32/64-bit x 2 22 22 T * volatile top; // pointer to stack top 23 uintptr_t count; // count each push23 uintptr_t count; // count each push 24 24 }; 25 25 #if __SIZEOF_INT128__ == 16 26 __int128 // gcc, 128-bit integer26 __int128 // gcc, 128-bit integer 27 27 #else 28 uint64_t // 64-bit integer28 uint64_t // 64-bit integer 29 29 #endif // __SIZEOF_INT128__ == 16 30 30 atom; 31 31 }; // Link 32 32 33 forall( otype T | { Link(T) * ?`next( T * ); } ) {33 forall( otype T | sized(T) | { Link(T) * ?`next( T * ); } ) { 34 34 struct StackLF { 35 35 Link(T) stack; … … 42 42 43 43 void push( StackLF(T) & this, T & n ) with(this) { 44 *( &n )`next = stack; // atomic assignment unnecessary, or use CAA 44 45 for () { // busy wait 45 *( &n )`next = stack; // atomic assignment unnecessary, or use CAA46 46 if ( __atomic_compare_exchange_n( &stack.atom, &( &n )`next->atom, (Link(T))@{ {&n, ( &n )`next->count + 1} }.atom, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ) ) break; // attempt to update top node 47 47 } // for … … 49 49 50 50 T * pop( StackLF(T) & this ) with(this) { 51 Link(T) t @= {};51 Link(T) t @= stack; // atomic assignment unnecessary, or use CAA 52 52 for () { // busy wait 53 t = stack; // atomic assignment unnecessary, or use CAA54 53 if ( t.top == 0p ) return 0p; // empty stack ? 55 54 if ( __atomic_compare_exchange_n( &stack.atom, &t.atom, (Link(T))@{ {( t.top )`next->top, t.count} }.atom, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ) ) return t.top; // attempt to update top node -
libcfa/src/containers/vector.hfa
r9791ab5 r8b58bae 10 10 // Created On : Tue Jul 5 18:00:07 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 22 10:01:18 201713 // Update Count : 312 // Last Modified On : Wed Jun 17 11:02:46 2020 13 // Update Count : 4 14 14 // 15 15 16 16 #pragma once 17 17 18 extern "C" {19 18 #include <stdbool.h> 20 }21 19 22 20 //------------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.