trueno/backends/gpu/
runtime.rs1#[cfg(all(feature = "gpu", not(target_arch = "wasm32")))]
11pub fn block_on<F: std::future::Future>(f: F) -> F::Output {
12 pollster::block_on(f)
13}
14
15#[cfg(not(target_arch = "wasm32"))]
19pub const fn sync_available() -> bool {
20 true
21}
22
23#[cfg(target_arch = "wasm32")]
24pub const fn sync_available() -> bool {
25 false
26}
27
28#[cfg(all(feature = "gpu-wasm", target_arch = "wasm32"))]
30pub fn spawn_local<F>(f: F)
31where
32 F: std::future::Future<Output = ()> + 'static,
33{
34 wasm_bindgen_futures::spawn_local(f);
35}
36
37#[cfg(all(feature = "gpu-wasm", target_arch = "wasm32"))]
39pub fn console_log(s: &str) {
40 web_sys::console::log_1(&s.into());
41}
42
43#[cfg(not(target_arch = "wasm32"))]
44pub fn console_log(s: &str) {
45 eprintln!("{}", s);
46}