A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Update Func & TypedFunc's doc comments to explain Accessor and Store::run_concurrent (#12330)
Lorenzo Fontourab1c7887c801b
diff --git a/crates/wasmtime/src/runtime/component/func.rs b/crates/wasmtime/src/runtime/component/func.rsindex fb9d3138bf..2abb0b4b8b 100644--- a/crates/wasmtime/src/runtime/component/func.rs+++ b/crates/wasmtime/src/runtime/component/func.rs@@ -312,6 +312,9 @@ impl Func {/// Start a concurrent call to this function.///+ /// Concurrency is achieved by relying on the [`Accessor`] argument, which+ /// can be obtained by calling [`StoreContextMut::run_concurrent`].+ ////// Unlike [`Self::call`] and [`Self::call_async`] (both of which require/// exclusive access to the store until the completion of the call), calls/// made using this method may run concurrently with other calls to the same@@ -368,6 +371,37 @@ impl Func {////// Panics if the store that the [`Accessor`] is derived from does not own/// this function.+ ///+ /// # Example+ ///+ /// Using [`StoreContextMut::run_concurrent`] to get an [`Accessor`]:+ ///+ /// ```+ /// # use {+ /// # wasmtime::{+ /// # error::{Result},+ /// # component::{Component, Linker, ResourceTable},+ /// # Config, Engine, Store+ /// # },+ /// # };+ /// #+ /// # struct Ctx { table: ResourceTable }+ /// #+ /// # async fn foo() -> Result<()> {+ /// # let mut config = Config::new();+ /// # let engine = Engine::new(&config)?;+ /// # let mut store = Store::new(&engine, Ctx { table: ResourceTable::new() });+ /// # let mut linker = Linker::new(&engine);+ /// # let component = Component::new(&engine, "")?;+ /// # let instance = linker.instantiate_async(&mut store, &component).await?;+ /// let my_func = instance.get_func(&mut store, "my_func").unwrap();+ /// store.run_concurrent(async |accessor| -> wasmtime::Result<_> {+ /// my_func.call_concurrent(accessor, &[], &mut Vec::new()).await?;+ /// Ok(())+ /// }).await??;+ /// # Ok(())+ /// # }+ /// ```#[cfg(feature = "component-model-async")]pub async fn call_concurrent(self,diff --git a/crates/wasmtime/src/runtime/component/func/typed.rs b/crates/wasmtime/src/runtime/component/func/typed.rsindex add17eddea..cb466d5bd4 100644--- a/crates/wasmtime/src/runtime/component/func/typed.rs+++ b/crates/wasmtime/src/runtime/component/func/typed.rs@@ -252,6 +252,9 @@ where/// Start a concurrent call to this function.///+ /// Concurrency is achieved by relying on the [`Accessor`] argument, which+ /// can be obtained by calling [`StoreContextMut::run_concurrent`].+ ////// Unlike [`Self::call`] and [`Self::call_async`] (both of which require/// exclusive access to the store until the completion of the call), calls/// made using this method may run concurrently with other calls to the same@@ -275,6 +278,37 @@ where////// Panics if the store that the [`Accessor`] is derived from does not own/// this function.+ ///+ /// # Example+ ///+ /// Using [`StoreContextMut::run_concurrent`] to get an [`Accessor`]:+ ///+ /// ```+ /// # use {+ /// # wasmtime::{+ /// # error::{Result},+ /// # component::{Component, Linker, ResourceTable},+ /// # Config, Engine, Store+ /// # },+ /// # };+ /// #+ /// # struct Ctx { table: ResourceTable }+ /// #+ /// # async fn foo() -> Result<()> {+ /// # let mut config = Config::new();+ /// # let engine = Engine::new(&config)?;+ /// # let mut store = Store::new(&engine, Ctx { table: ResourceTable::new() });+ /// # let mut linker = Linker::new(&engine);+ /// # let component = Component::new(&engine, "")?;+ /// # let instance = linker.instantiate_async(&mut store, &component).await?;+ /// let my_typed_func = instance.get_typed_func::<(), ()>(&mut store, "my_typed_func")?;+ /// store.run_concurrent(async |accessor| -> wasmtime::Result<_> {+ /// my_typed_func.call_concurrent(accessor, ()).await?;+ /// Ok(())+ /// }).await??;+ /// # Ok(())+ /// # }+ /// ```#[cfg(feature = "component-model-async")]pub async fn call_concurrent(self,