1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-24 17:27:18 +00:00

Sleep can take non integer times in seconds.

This commit is contained in:
Calvin Rose 2018-07-05 12:55:11 -04:00
parent 944ee5a9fb
commit bfd0c08c8f

View File

@ -98,16 +98,16 @@ static int os_clock(DstArgs args) {
}
static int os_sleep(DstArgs args) {
int32_t delay;
double delay;
DST_FIXARITY(args, 1);
DST_ARG_INTEGER(delay, args, 0);
DST_ARG_NUMBER(delay, args, 0);
if (delay < 0) {
DST_THROW(args, "invalid argument to sleep");
}
#ifdef DST_WINDOWS
Sleep(delay);
Sleep((DWORD) (delay * 1000));
#else
sleep((unsigned int) delay);
usleep((useconds_t)(delay * 1000000));
#endif
return 0;
}