ling-wasm
↓ 0 downloadsLing language — WebGL2 WASM runtime
lingfu install ling-wasmCode / Files (13)
pkg/snippets/ling-lang-be3fd50f9061de6b/inline0.js
export function ling_sleep_ms(ms) {
const t = Math.max(0, ms | 0);
if (t <= 0) return;
try {
if (typeof SharedArrayBuffer === 'function'
&& typeof Atomics === 'object'
&& typeof Atomics.wait === 'function') {
const sab = new SharedArrayBuffer(4);
const i32 = new Int32Array(sab);
Atomics.wait(i32, 0, 0, t);
return;
}
} catch (_) {}
const end = Date.now() + t;
while (Date.now() < end) {}
}