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

@@ -14,6 +14,6 @@ fn main() {
l := r.read_line() or { break }
println('$l')
// Make it nice and obvious that we are doing this line by line
time.wait(100 * time.millisecond)
time.sleep(100 * time.millisecond)
}
}

View File

@@ -3,7 +3,7 @@ import time
// Simulate expensive computing using sleep function
fn expensive_computing(id int, duration int) {
println('Executing expensive computing task ($id)...')
time.wait(duration * time.millisecond)
time.sleep(duration * time.millisecond)
println('Finish task $id on $duration ms')
}

View File

@@ -206,7 +206,7 @@ fn main() {
fn (mut app App) run() {
for {
app.update()
time.wait(app.timer_period_ms * time.millisecond)
time.sleep(app.timer_period_ms * time.millisecond)
}
}

View File

@@ -20,6 +20,6 @@ fn main() {
for {
a.update()
print_automaton(a)
time.wait(100 * time.millisecond)
time.sleep(100 * time.millisecond)
}
}

View File

@@ -80,6 +80,6 @@ fn (mut game Game) update_model() {
fn (mut game Game) run() {
for {
game.update_model()
time.wait(16 * time.millisecond) // 60fps
time.sleep(16 * time.millisecond) // 60fps
}
}

View File

@@ -13,6 +13,6 @@ fn print_message() {
fn main() {
for {
print_message()
time.wait(500 * time.millisecond)
time.sleep(500 * time.millisecond)
}
}

View File

@@ -30,7 +30,7 @@ fn (l Lander) open_parachutes(n int) {
fn wait() {
println('waiting...')
time.wait(1 * time.second)
time.sleep(1 * time.second)
}
fn (l Lander) land(w World) {

View File

@@ -37,6 +37,6 @@ fn main() {
audio.setup(
stream_cb: my_audio_stream_callback
)
time.wait(2000 * time.millisecond)
time.sleep(2000 * time.millisecond)
audio.shutdown()
}

View File

@@ -72,7 +72,7 @@ fn (mut p Player) play_wav_file(fpath string) ? {
p.samples << samples
p.finished = false
for !p.finished {
time.wait(16 * time.millisecond)
time.sleep(16 * time.millisecond)
}
p.free()
}

View File

@@ -218,7 +218,7 @@ fn (mut g Game) run() {
g.delete_completed_lines()
}
// glfw.post_empty_event() // force window redraw
time.wait(timer_period * time.millisecond)
time.sleep(timer_period * time.millisecond)
}
}

View File

@@ -32,7 +32,7 @@ fn (mut app App) sse() vweb.Result {
data := '{"time": "$time.now().str()", "random_id": "$rand.ulid()"}'
session.send_message(event: 'ping', data: data) or { return app.server_error(501) }
println('> sent event: $data')
time.wait(1 * time.second)
time.sleep(1 * time.second)
}
return app.server_error(501)
}

View File

@@ -7,7 +7,7 @@ import x.websocket
fn main() {
println('press enter to quit...\n')
go start_server()
time.wait(100 * time.millisecond)
time.sleep(100 * time.millisecond)
go start_client()
os.get_line()
}
@@ -76,7 +76,7 @@ fn write_echo(mut ws websocket.Client) ? {
for i := 0; i <= 10; i++ {
// Server will send pings every 30 seconds
ws.write_str(message) or { println('panicing writing $err') }
time.wait(100 * time.millisecond)
time.sleep(100 * time.millisecond)
}
ws.close(1000, 'normal') or { println('panicing $err') }
}