Update core:sync/sync2 to have a generic Futex interface, and implement the calls appropriately for each platform
This commit is contained in:
1 parent
d386563344
commit
2ef0e6b8f6
11 files changed
+486
-402
No files matched your search
@@ -251,17 +251,18 @@ Once :: struct {
|
||||
}
|
||||
|
||||
once_do :: proc(o: ^Once, fn: proc()) {
|
||||
if atomic_load_acquire(&o.done) == false {
|
||||
_once_do_slow(o, fn)
|
||||
@(cold)
|
||||
do_slow :: proc(o: ^Once, fn: proc()) {
|
||||
mutex_lock(&o.m)
|
||||
defer mutex_unlock(&o.m)
|
||||
if !o.done {
|
||||
fn()
|
||||
atomic_store_release(&o.done, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@(cold)
|
||||
_once_do_slow :: proc(o: ^Once, fn: proc()) {
|
||||
mutex_lock(&o.m)
|
||||
defer mutex_unlock(&o.m)
|
||||
if !o.done {
|
||||
fn()
|
||||
atomic_store_release(&o.done, true)
|
||||
|
||||
if atomic_load_acquire(&o.done) == false {
|
||||
do_slow(o, fn)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user