From c37daba41d2a2b01ec7bec93b5796f9c4fa0b937 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 22 Feb 2021 09:12:23 +0200 Subject: [PATCH] ci: fix the remaining obsolete reference to time.sleep and time.usleep --- doc/docs.md | 4 ++-- vlib/benchmark/README.md | 4 ++-- vlib/term/ui/input_windows.c.v | 2 +- vlib/v/fmt/tests/shared_expected.vv | 8 ++++---- vlib/v/fmt/tests/shared_input.vv | 8 ++++---- vlib/v/parser/parser.v | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/doc/docs.md b/doc/docs.md index 360ad93900..fa36ddd77b 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -2576,7 +2576,7 @@ import time fn task(id int, duration int, mut wg sync.WaitGroup) { println('task $id begin') - time.sleep_ms(duration) + time.wait(duration * time.millisecond) println('task $id end') wg.done() } @@ -3841,7 +3841,7 @@ fn print_message() { fn main() { for { print_message() - time.sleep_ms(500) + time.wait(500 * time.millisecond) } } ``` diff --git a/vlib/benchmark/README.md b/vlib/benchmark/README.md index bb6667a0c0..ca1f86f641 100644 --- a/vlib/benchmark/README.md +++ b/vlib/benchmark/README.md @@ -31,10 +31,10 @@ import benchmark mut b := benchmark.start() // your code section 1 ... -time.sleep_ms(1500) +time.wait(1500 * time.millisecond) b.measure('code_1') // your code section 2 ... -time.sleep_ms(500) +time.wait(500 * time.millisecond) b.measure('code_2') ``` diff --git a/vlib/term/ui/input_windows.c.v b/vlib/term/ui/input_windows.c.v index ac4f9316b0..406ca85ae4 100644 --- a/vlib/term/ui/input_windows.c.v +++ b/vlib/term/ui/input_windows.c.v @@ -107,7 +107,7 @@ pub fn (mut ctx Context) run() ? { init_called = true } if sleep_len > 0 { - time.usleep(sleep_len) + time.wait(sleep_len * time.microsecond) } if !ctx.paused { sw.restart() diff --git a/vlib/v/fmt/tests/shared_expected.vv b/vlib/v/fmt/tests/shared_expected.vv index d47e37f0b0..c65774fb46 100644 --- a/vlib/v/fmt/tests/shared_expected.vv +++ b/vlib/v/fmt/tests/shared_expected.vv @@ -8,7 +8,7 @@ mut: fn (shared x St) f(shared z St) { for _ in 0 .. reads_per_thread { rlock x { // other instances may read at the same time - time.sleep_ms(1) + time.wait(time.millisecond) assert x.a == 7 || x.a == 5 } } @@ -65,10 +65,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 value should never be read - time.sleep_ms(50) + time.wait(50 * time.millisecond) x.a = if (i & 1) == 0 { 7 } else { 5 } } // now new reads are possible again - time.sleep_ms(20) + time.wait(20 * time.millisecond) } // wait until all read threads are finished for finished := false; true; { @@ -80,6 +80,6 @@ fn test_shared_lock() { if finished { break } - time.sleep_ms(100) + time.wait(100 * time.millisecond) } } diff --git a/vlib/v/fmt/tests/shared_input.vv b/vlib/v/fmt/tests/shared_input.vv index 77961b98f1..90d1f816e3 100644 --- a/vlib/v/fmt/tests/shared_input.vv +++ b/vlib/v/fmt/tests/shared_input.vv @@ -9,7 +9,7 @@ mut: fn (shared x St) f(shared z St) { for _ in 0 .. reads_per_thread { rlock x { // other instances may read at the same time - time.sleep_ms(1) + time.wait(time.millisecond) assert x.a == 7 || x.a == 5 } } @@ -63,11 +63,11 @@ a: 5 for i in 0..writes { lock x { // wait for ongoing reads to finish, don't start new ones x.a = 17 // this value should never be read - time.sleep_ms(50) + time.wait(50* time.millisecond) x.a = if (i & 1) == 0 { 7} else {5} } // now new reads are possible again -time.sleep_ms(20) +time.wait(20*time.millisecond) } // wait until all read threads are finished for finished:=false;; { @@ -79,6 +79,6 @@ for finished:=false;; { if finished { break } - time.sleep_ms(100) + time.wait(100*time.millisecond) } } diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 63091b4a13..efc324bd1f 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -305,7 +305,7 @@ pub fn parse_files(paths []string, table &table.Table, pref &pref.Preferences, g for _ in 0 .. nr_cpus - 1 { go q.run() } - time.sleep_ms(1000) + time.wait(time.second) println('all done') return q.parsed_ast_files }