Does wasmtime plan to support nested calls and concurrent calls to multiple instance?
Func::Call
takes &mut Store
, the host can't call the client back again.Some use case: Client pass callback functions to host function that will be invoked immediately. Like:
Client:
let list = [1, 2, 3];
host_sort_fn(list, callback_to_id(|a, b| a > b));
Host:
fn host_sort_fn(list: Vec<i32>, callback_id: i32) {
let func = instance.get_func(&mut store, "invoke_callback");
list.sort_by(|a, b| func.call(&mut store, (callback_id, a, b)));
// ...
}
Concurrent Call
If two instances can interact with each other, then they can't safely be called concurrently (in general). If the instances cannot interact then they probably don't need to use the same Store
Nested calls are supported though because host functions get access to a Caller which can be used as the store argument
Alex Crichton said:
Nested calls are supported though because host functions get access to a Caller which can be used as the store argument
You're right. But if I'm not wrong we can't do that with component model now. At least the trait generated by the bindgen only give access to the store data.
Last updated: Nov 22 2024 at 17:03 UTC