Skip to main content

Module time

Module time 

Source
Expand description

引擎读取的单调时钟。原生平台就是 std::time::Instant;wasm32-unknown-unknown 的 std 没有时钟,std::time::Instant::now 会 panic,所以那里换成宿主经 set_host_clock 注入的毫秒读数(浏览器里是 performance.now() 和 Date.now())。注入之前 Instant::now() 返回零点,经过的时间读作 0,不会 panic。

Structs§

HostClock
宿主提供的两个时钟读数,都是毫秒。
Instant
A measurement of a monotonically nondecreasing clock. Opaque and useful only with Duration.

Functions§

host_wall_ms
wasm 上没有注入时返回 None
set_host_clock
只在 wasm 上有效;原生平台是空操作