mirror of
https://github.com/janet-lang/janet
synced 2025-07-27 14:22:57 +00:00
Sleep can take non integer times in seconds.
This commit is contained in:
parent
944ee5a9fb
commit
bfd0c08c8f
@ -98,16 +98,16 @@ static int os_clock(DstArgs args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int os_sleep(DstArgs args) {
|
static int os_sleep(DstArgs args) {
|
||||||
int32_t delay;
|
double delay;
|
||||||
DST_FIXARITY(args, 1);
|
DST_FIXARITY(args, 1);
|
||||||
DST_ARG_INTEGER(delay, args, 0);
|
DST_ARG_NUMBER(delay, args, 0);
|
||||||
if (delay < 0) {
|
if (delay < 0) {
|
||||||
DST_THROW(args, "invalid argument to sleep");
|
DST_THROW(args, "invalid argument to sleep");
|
||||||
}
|
}
|
||||||
#ifdef DST_WINDOWS
|
#ifdef DST_WINDOWS
|
||||||
Sleep(delay);
|
Sleep((DWORD) (delay * 1000));
|
||||||
#else
|
#else
|
||||||
sleep((unsigned int) delay);
|
usleep((useconds_t)(delay * 1000000));
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user