improve sleep timer resolution on windows

This commit is contained in:
2022-05-08 16:59:59 +02:00
parent b2b990333e
commit 8e9bb002bc
3 changed files with 7 additions and 2 deletions

1
Cargo.lock generated
View File

@@ -2655,6 +2655,7 @@ dependencies = [
"wasmtime", "wasmtime",
"wat", "wat",
"webbrowser", "webbrowser",
"winapi 0.3.9",
] ]
[[package]] [[package]]

View File

@@ -7,7 +7,7 @@ edition = "2021"
[features] [features]
default = ["native", "browser"] default = ["native", "browser"]
native = ["wasmtime", "minifb", "cpal", "rubato"] native = ["wasmtime", "minifb", "cpal", "rubato", "winapi" ]
browser = ["warp", "tokio", "tokio-stream", "webbrowser"] browser = ["warp", "tokio", "tokio-stream", "webbrowser"]
[dependencies] [dependencies]
@@ -26,4 +26,5 @@ tokio-stream = { version = "0.1.8", features = ["sync"], optional = true }
webbrowser = { version = "0.6.0", optional = true } webbrowser = { version = "0.6.0", optional = true }
ansi_term = "0.12.1" ansi_term = "0.12.1"
cpal = { version = "0.13.5", optional = true } cpal = { version = "0.13.5", optional = true }
rubato = { version = "0.11.0", optional = true } rubato = { version = "0.11.0", optional = true }
winapi = { version = "0.3.9", features = ["timeapi"], optional = true }

View File

@@ -59,6 +59,9 @@ struct UW8WatchDog {
impl MicroW8 { impl MicroW8 {
pub fn new() -> Result<MicroW8> { pub fn new() -> Result<MicroW8> {
#[cfg(target_os = "windows")]
unsafe { winapi::um::timeapi::timeBeginPeriod(1); }
let engine = wasmtime::Engine::new(wasmtime::Config::new().interruptable(true))?; let engine = wasmtime::Engine::new(wasmtime::Config::new().interruptable(true))?;
let loader_module = let loader_module =