Swift Atomic Compare and Swap func
Machx opened this issue · comments
Colin Wheeler commented
// roughly equivalent to
// lock.lock()
// if shouldDoThing == true {
// shouldDoThing = false
// print(shouldDoThing)
// }
// lock.unlock
if AtomicCompareAndSwap(shouldDoThing, expecting: true, replaceWith: false) {
print(shouldDoThing) // false
}
Colin Wheeler commented
This suffers from the problem of not knowing how to lock a specific thing and that thing only. It's almost like we'd have to make an extension on any and make a lock var for each variable somehow.
Colin Wheeler commented
I am going to close this in this repository and instead move this issue to a more experimental repository where this concept can be explored until it is mature.