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 ManyTimes {
mut:
@@ -21,7 +21,7 @@ pub fn new_many_times(times u64) &ManyTimes {
// do execute the function only setting times.
pub fn (mut m ManyTimes) do(f fn ()) {
if atomic2.load_u64(&m.count) < m.times {
if stdatomic.load_u64(&m.count) < m.times {
m.do_slow(f)
}
}
@@ -29,7 +29,7 @@ pub fn (mut m ManyTimes) do(f fn ()) {
fn (mut m ManyTimes) do_slow(f fn ()) {
m.m.@lock()
if m.count < m.times {
atomic2.store_u64(&m.count, m.count + 1)
stdatomic.store_u64(&m.count, m.count + 1)
f()
}
m.m.unlock()