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

time: consolidate the different sleep functions into time.wait(Duration) (#8853)

This commit is contained in:
zakuro
2021-02-22 00:05:03 +09:00
committed by GitHub
parent b1209aac1b
commit ac4791045f
49 changed files with 156 additions and 179 deletions

View File

@@ -36,7 +36,6 @@ fn main() {
os.system('git push origin gh-pages')
os.chdir('..')
}
// println('sleeping 60')
time.sleep(60)
time.wait(60 * time.second)
}
}

View File

@@ -44,7 +44,7 @@ fn (mut ctx Context) println(s string) {
fn do_timeout(c &Context) {
mut ctx := c
time.sleep_ms(ctx.timeout_ms)
time.wait(ctx.timeout_ms * time.millisecond)
exit(ctx.exitcode)
}
@@ -58,7 +58,7 @@ fn main() {
After a while (-timeout_ms), exit with (-exitcode).
This program is useful for platform independent testing
of child process/standart input/output control.
It is used in V\'s `os` module tests.
It is used in V's `os` module tests.
")
}
ctx.is_verbose = '-v' in args
@@ -75,7 +75,7 @@ fn main() {
go do_timeout(&ctx)
for i := 1; true; i++ {
ctx.println('$i')
time.sleep_ms(ctx.period_ms)
time.wait(ctx.period_ms * time.millisecond)
}
time.sleep(100000)
time.wait(100 * time.second)
}

View File

@@ -14,7 +14,7 @@ const (
ecode_timeout = 101
ecode_memout = 102
ecode_exec = 103
ecode_details = {
ecode_details = map{
'101': 'too slow'
'102': 'too memory hungry'
'103': 'worker executable not found'
@@ -60,7 +60,7 @@ fn main() {
source = source[..context.cut_index]
go fn (ms int) {
time.sleep_ms(ms)
time.wait(ms * time.millisecond)
exit(ecode_timeout)
}(context.timeout_ms)
_ := parser.parse_text(source, context.path, context.table, .skip_comments, context.pref,
@@ -259,7 +259,7 @@ fn (mut context Context) start_printing() {
fn (mut context Context) stop_printing() {
context.stop_print = true
time.sleep_ms(context.period_ms / 5)
time.wait(time.millisecond * context.period_ms / 5)
}
fn (mut context Context) print_status() {
@@ -284,7 +284,7 @@ fn (mut context Context) print_periodic_status() {
for !context.stop_print {
context.print_status()
for i := 0; i < 10 && !context.stop_print; i++ {
time.sleep_ms(context.period_ms / 10)
time.wait(time.millisecond * context.period_ms / 10)
if context.cut_index > 50 && !printed_at_least_once {
context.print_status()
printed_at_least_once = true