1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

sync: move sync.atomic2 to sync.stdatomic, cleanup

This commit is contained in:
Delyan Angelov
2021-12-28 10:12:40 +02:00
parent c1711b8f05
commit 730b2a9263
7 changed files with 162 additions and 188 deletions

View File

@@ -1,6 +1,6 @@
module sync
import sync.atomic2
import sync.stdatomic
pub struct Once {
mut:
@@ -18,7 +18,7 @@ pub fn new_once() &Once {
// do execute the function only once.
pub fn (mut o Once) do(f fn ()) {
if atomic2.load_u64(&o.count) < 1 {
if stdatomic.load_u64(&o.count) < 1 {
o.do_slow(f)
}
}
@@ -26,7 +26,7 @@ pub fn (mut o Once) do(f fn ()) {
fn (mut o Once) do_slow(f fn ()) {
o.m.@lock()
if o.count < 1 {
atomic2.store_u64(&o.count, 1)
stdatomic.store_u64(&o.count, 1)
f()
}
o.m.unlock()