Changeset 5ece8ce for libcfa/src/concurrency
- Timestamp:
- May 24, 2023, 11:45:39 AM (20 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 88b49bb
- Parents:
- 76e77a4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/locks.hfa
r76e77a4 r5ece8ce 176 176 static inline void ?{}(mcs_spin_node & this) { this.next = 0p; this.locked = true; } 177 177 178 static inline mcs_spin_node * volatile & ?`next ( mcs_spin_node * node ) {179 return node->next;180 }181 182 178 struct mcs_spin_lock { 183 179 mcs_spin_queue queue; … … 185 181 186 182 static inline void lock(mcs_spin_lock & l, mcs_spin_node & n) { 183 n.locked = true; 187 184 mcs_spin_node * prev = __atomic_exchange_n(&l.queue.tail, &n, __ATOMIC_SEQ_CST); 188 n.locked = true; 189 if(prev == 0p) return; 185 if( prev == 0p ) return; 190 186 prev->next = &n; 191 while( __atomic_load_n(&n.locked, __ATOMIC_RELAXED)) Pause();187 while( __atomic_load_n(&n.locked, __ATOMIC_RELAXED) ) Pause(); 192 188 } 193 189 … … 195 191 mcs_spin_node * n_ptr = &n; 196 192 if (__atomic_compare_exchange_n(&l.queue.tail, &n_ptr, 0p, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) return; 197 while (__atomic_load_n(&n.next, __ATOMIC_RELAXED) == 0p) {}193 while (__atomic_load_n(&n.next, __ATOMIC_RELAXED) == 0p) Pause(); 198 194 n.next->locked = false; 199 195 }
Note: See TracChangeset
for help on using the changeset viewer.