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

time: time.wait() => time.sleep()

This commit is contained in:
Alexander Medvednikov
2021-02-27 20:41:06 +03:00
parent be4a2e17d3
commit 3a2d696fac
42 changed files with 76 additions and 67 deletions

View File

@@ -8,7 +8,7 @@ mut:
fn f(shared x St, shared z St) {
for _ in 0 .. reads_per_thread {
rlock x { // other instances may read at the same time
time.wait(time.millisecond)
time.sleep(time.millisecond)
assert x.a == 7 || x.a == 5
}
}
@@ -37,10 +37,10 @@ fn test_shared_lock() {
for i in 0 .. writes {
lock x { // wait for ongoing reads to finish, don't start new ones
x.a = 17 // this should never be read
time.wait(50 * time.millisecond)
time.sleep(50 * time.millisecond)
x.a = if (i & 1) == 0 { 7 } else { 5 }
} // now new reads are possible again
time.wait(20 * time.millisecond)
time.sleep(20 * time.millisecond)
}
// wait until all read threads are finished
for finished := false; true; {
@@ -52,6 +52,6 @@ fn test_shared_lock() {
if finished {
break
}
time.wait(100 * time.millisecond)
time.sleep(100 * time.millisecond)
}
}