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

Function thread_index_via_call

tests/all/component_model/func.rs:3127–3151  ·  view source on GitHub ↗
(style: ApiStyle)

Source from the content-addressed store, hash-verified

3125}
3126
3127async fn thread_index_via_call(style: ApiStyle) -> Result<()> {
3128 let component = r#"
3129(component
3130 (core module $m
3131 (import "" "thread.index" (func $thread-index (result i32)))
3132 (func (export "run")
3133 (if (i32.eqz (call $thread-index)) (then unreachable))
3134 )
3135 )
3136 (core func $thread-index (canon thread.index))
3137 (core instance $m (instantiate $m (with "" (instance
3138 (export "thread.index" (func $thread-index))
3139 ))))
3140 (func (export "run") (canon lift (core func $m "run")))
3141)
3142"#;
3143 let engine = Engine::new(&style.config())?;
3144 let component = Component::new(&engine, component)?;
3145 let mut store = Store::new(&engine, ());
3146 let linker = Linker::new(&engine);
3147 let instance = style.instantiate(&mut store, &linker, &component).await?;
3148 let run = instance.get_typed_func::<(), ()>(&mut store, "run")?;
3149 style.call(&mut store, run, ()).await?;
3150 Ok(())
3151}
3152
3153#[tokio::test]
3154async fn thread_index_via_post_return_sync() -> Result<()> {

Callers 3

Calls 5

OkFunction · 0.85
newFunction · 0.50
configMethod · 0.45
instantiateMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected