v2 / vlib / os / sleeping.js.v
10 lines · 8 sloc · 312 bytes · 0eb71e680b335628756d7e1406bc1030f8b9ff59
Raw
1module os
2
3// sleep_ms suspends the execution for a given duration (in milliseconds), without having to `import time` for a single time.sleep/1 call.
4fn sleep_ms(dur i64) {
5 #let now = new Date().getTime()
6 #let toWait = BigInt(dur)
7 #while (new Date().getTime() < now + Number(toWait)) {}
8
9 _ = dur // unused
10}
11