MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / epoch_events

Function epoch_events

tests/all/debug.rs:987–1027  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

985#[tokio::test]
986#[cfg_attr(miri, ignore)]
987async fn epoch_events() -> wasmtime::Result<()> {
988 let _ = env_logger::try_init();
989
990 let (module, mut store) = get_module_and_store(
991 |config| {
992 config.epoch_interruption(true);
993 },
994 r#"
995 (module
996 (func $f (export "f") (param i32 i32) (result i32)
997 local.get 0
998 local.get 1
999 i32.add))
1000 "#,
1001 )?;
1002
1003 debug_event_checker!(
1004 D, store,
1005 { 0 ;
1006 wasmtime::DebugEvent::EpochYield => {}
1007 }
1008 );
1009
1010 let (handler, counter) = D::new_and_counter();
1011 store.set_debug_handler(handler);
1012
1013 store.set_epoch_deadline(1);
1014 store.epoch_deadline_async_yield_and_update(1);
1015 store.engine().increment_epoch();
1016
1017 let instance = Instance::new_async(&mut store, &module, &[]).await?;
1018 let func_f = instance.get_func(&mut store, "f").unwrap();
1019 let mut results = [Val::I32(0)];
1020 func_f
1021 .call_async(&mut store, &[Val::I32(1), Val::I32(2)], &mut results)
1022 .await?;
1023 assert_eq!(counter.load(Ordering::Relaxed), 1);
1024 assert_eq!(results[0].unwrap_i32(), 3);
1025
1026 Ok(())
1027}
1028
1029#[tokio::test]
1030#[cfg_attr(miri, ignore)]

Callers

nothing calls this directly

Calls 11

get_module_and_storeFunction · 0.85
OkFunction · 0.85
set_debug_handlerMethod · 0.80
epoch_interruptionMethod · 0.45
set_epoch_deadlineMethod · 0.45
increment_epochMethod · 0.45
engineMethod · 0.45
unwrapMethod · 0.45
get_funcMethod · 0.45
call_asyncMethod · 0.45

Tested by

no test coverage detected