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

@@ -325,31 +325,21 @@ pub fn ticks() i64 {
}
// sleep makes the calling thread sleep for a given number of seconds.
[deprecated: 'call time.wait(n * time.second)']
pub fn sleep(seconds int) {
$if windows {
C.Sleep(seconds * 1000)
} $else {
C.sleep(seconds)
}
wait(seconds * time.second)
}
// sleep_ms makes the calling thread sleep for a given number of milliseconds.
[deprecated: 'call time.wait(n * time.millisecond)']
pub fn sleep_ms(milliseconds int) {
$if windows {
C.Sleep(milliseconds)
} $else {
C.usleep(milliseconds * 1000)
}
wait(milliseconds * time.millisecond)
}
// usleep makes the calling thread sleep for a given number of microseconds.
[deprecated: 'call time.wait(n * time.microsecond)']
pub fn usleep(microseconds int) {
$if windows {
milliseconds := microseconds / 1000
C.Sleep(milliseconds)
} $else {
C.usleep(microseconds)
}
wait(microseconds * time.microsecond)
}
// is_leap_year checks if a given a year is a leap year.