all: fix references to time.wait -> time.sleep
parent
bdce35fd9c
commit
4125bfe401
|
@ -2579,7 +2579,7 @@ import time
|
||||||
|
|
||||||
fn task(id int, duration int) {
|
fn task(id int, duration int) {
|
||||||
println('task $id begin')
|
println('task $id begin')
|
||||||
time.wait(duration * time.millisecond)
|
time.sleep(duration * time.millisecond)
|
||||||
println('task $id end')
|
println('task $id end')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3868,7 +3868,7 @@ fn print_message() {
|
||||||
fn main() {
|
fn main() {
|
||||||
for {
|
for {
|
||||||
print_message()
|
print_message()
|
||||||
time.wait(500 * time.millisecond)
|
time.sleep(500 * time.millisecond)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -31,10 +31,10 @@ import benchmark
|
||||||
|
|
||||||
mut b := benchmark.start()
|
mut b := benchmark.start()
|
||||||
// your code section 1 ...
|
// your code section 1 ...
|
||||||
time.wait(1500 * time.millisecond)
|
time.sleep(1500 * time.millisecond)
|
||||||
b.measure('code_1')
|
b.measure('code_1')
|
||||||
// your code section 2 ...
|
// your code section 2 ...
|
||||||
time.wait(500 * time.millisecond)
|
time.sleep(500 * time.millisecond)
|
||||||
b.measure('code_2')
|
b.measure('code_2')
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ mut:
|
||||||
fn (shared x St) f(shared z St) {
|
fn (shared x St) f(shared z St) {
|
||||||
for _ in 0 .. reads_per_thread {
|
for _ in 0 .. reads_per_thread {
|
||||||
rlock x { // other instances may read at the same time
|
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
|
assert x.a == 7 || x.a == 5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,10 +65,10 @@ fn test_shared_lock() {
|
||||||
for i in 0 .. writes {
|
for i in 0 .. writes {
|
||||||
lock x { // wait for ongoing reads to finish, don't start new ones
|
lock x { // wait for ongoing reads to finish, don't start new ones
|
||||||
x.a = 17 // this value should never be read
|
x.a = 17 // this value should never be read
|
||||||
time.wait(50 * time.millisecond)
|
time.sleep(50 * time.millisecond)
|
||||||
x.a = if (i & 1) == 0 { 7 } else { 5 }
|
x.a = if (i & 1) == 0 { 7 } else { 5 }
|
||||||
} // now new reads are possible again
|
} // now new reads are possible again
|
||||||
time.wait(20 * time.millisecond)
|
time.sleep(20 * time.millisecond)
|
||||||
}
|
}
|
||||||
// wait until all read threads are finished
|
// wait until all read threads are finished
|
||||||
for finished := false; true; {
|
for finished := false; true; {
|
||||||
|
@ -80,6 +80,6 @@ fn test_shared_lock() {
|
||||||
if finished {
|
if finished {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
time.wait(100 * time.millisecond)
|
time.sleep(100 * time.millisecond)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ mut:
|
||||||
fn (shared x St) f(shared z St) {
|
fn (shared x St) f(shared z St) {
|
||||||
for _ in 0 .. reads_per_thread {
|
for _ in 0 .. reads_per_thread {
|
||||||
rlock x { // other instances may read at the same time
|
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
|
assert x.a == 7 || x.a == 5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,11 +63,11 @@ a: 5
|
||||||
for i in 0..writes {
|
for i in 0..writes {
|
||||||
lock x { // wait for ongoing reads to finish, don't start new ones
|
lock x { // wait for ongoing reads to finish, don't start new ones
|
||||||
x.a = 17 // this value should never be read
|
x.a = 17 // this value should never be read
|
||||||
time.wait(50* time.millisecond)
|
time.sleep(50* time.millisecond)
|
||||||
x.a = if (i & 1) == 0 {
|
x.a = if (i & 1) == 0 {
|
||||||
7} else {5}
|
7} else {5}
|
||||||
} // now new reads are possible again
|
} // now new reads are possible again
|
||||||
time.wait(20*time.millisecond)
|
time.sleep(20*time.millisecond)
|
||||||
}
|
}
|
||||||
// wait until all read threads are finished
|
// wait until all read threads are finished
|
||||||
for finished:=false;; {
|
for finished:=false;; {
|
||||||
|
@ -79,6 +79,6 @@ for finished:=false;; {
|
||||||
if finished {
|
if finished {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
time.wait(100*time.millisecond)
|
time.sleep(100*time.millisecond)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ fn main() {
|
||||||
if s == 'STOP' {
|
if s == 'STOP' {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
time.wait(delay * time.millisecond)
|
time.sleep(delay * time.millisecond)
|
||||||
}
|
}
|
||||||
pmessage()
|
pmessage()
|
||||||
pmessage()
|
pmessage()
|
||||||
|
|
Loading…
Reference in New Issue