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

Function timeout_async_hook

tests/all/component_model/call_hook.rs:402–490  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

400
401#[tokio::test]
402async fn timeout_async_hook() -> Result<()> {
403 struct HandlerR;
404
405 #[async_trait::async_trait]
406 impl CallHookHandler<State> for HandlerR {
407 async fn handle_call_event(
408 &self,
409 mut ctx: StoreContextMut<'_, State>,
410 ch: CallHook,
411 ) -> Result<()> {
412 let obj = ctx.data_mut();
413 if obj.calls_into_host > 200 {
414 bail!("timeout");
415 }
416
417 match ch {
418 CallHook::CallingHost => obj.calls_into_host += 1,
419 CallHook::CallingWasm => obj.calls_into_wasm += 1,
420 CallHook::ReturningFromHost => obj.returns_from_host += 1,
421 CallHook::ReturningFromWasm => obj.returns_from_wasm += 1,
422 }
423
424 Ok(())
425 }
426 }
427
428 let wat = r#"
429 (component
430 (import "f" (func $f))
431
432 (core func $f_lower
433 (canon lower (func $f))
434 )
435 (core module $m
436 (import "" "" (func $f))
437
438 (func $export
439 (loop $start
440 (call $f)
441 (br $start))
442 )
443
444 (export "export" (func $export))
445 )
446 (core instance $i (instantiate $m
447 (with "" (instance
448 (export "" (func $f_lower))
449 ))
450 ))
451 (func (export "export")
452 (canon lift
453 (core func $i "export")
454 )
455 )
456 )
457 "#;
458
459 let engine = Engine::default();

Callers

nothing calls this directly

Calls 9

OkFunction · 0.85
call_hook_asyncMethod · 0.80
into_dataMethod · 0.80
newFunction · 0.50
func_wrap_asyncMethod · 0.45
rootMethod · 0.45
expectMethod · 0.45
instantiate_asyncMethod · 0.45
call_asyncMethod · 0.45

Tested by

no test coverage detected