mirror of
https://github.com/ValKmjolnir/Nasal-Interpreter.git
synced 2026-07-21 18:38:44 +08:00
🚀 change usleep in builtin_sleep to cross platform c++11::std::this_thread::sleep_for.
Although this is not so accurate in Windows platform, the accuracy is still improved and this line of code does not need MinGW to build on Windows platform.
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
+1
-1
@@ -1037,7 +1037,7 @@ nasal_ref builtin_sleep(nasal_ref* local,nasal_gc& gc)
|
||||
nasal_ref val=local[1];
|
||||
if(val.type!=vm_num)
|
||||
return builtin_err("sleep","\"duration\" must be number");
|
||||
usleep((useconds_t)(val.num()*1e6));
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(int64_t(val.num()*1e6)));
|
||||
return nil;
|
||||
}
|
||||
nasal_ref builtin_pipe(nasal_ref* local,nasal_gc& gc)
|
||||
|
||||
Reference in New Issue
Block a user