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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user