Reword get_export mutable context docs to be more user-facing
This commit is contained in:
@@ -303,19 +303,9 @@ impl Instance {
|
|||||||
/// # Why does `get_export` take a mutable context?
|
/// # Why does `get_export` take a mutable context?
|
||||||
///
|
///
|
||||||
/// This method requires a mutable context because an instance's exports are
|
/// This method requires a mutable context because an instance's exports are
|
||||||
/// lazily populated. While `wasmtime` could use interior mutability to
|
/// lazily populated, and we cache them as they are accessed. This makes
|
||||||
/// paper over this, since getting an export is "logically" a non-mutating
|
/// instantiating a module faster, but also means this method requires a
|
||||||
/// operation, this would bring with it a new problem. `wasmtime` would have
|
/// mutable context.
|
||||||
/// to choose whether to use a mutex or `RefCell` for the interior
|
|
||||||
/// mutability; the former implies unnecessasry overhead for single-threaded
|
|
||||||
/// usage, while the latter would prohibit `Store` from implementing `Send`
|
|
||||||
/// and `Sync`, making multi-threaded usage impossible.
|
|
||||||
///
|
|
||||||
/// Given these trade offs -- and because `wasmtime` will not stop lazily
|
|
||||||
/// populating exports, because this makes instantiation faster -- we
|
|
||||||
/// decided that the best option is to avoid interior mutability and expose
|
|
||||||
/// what's happening under the covers to users via requiring a mutable
|
|
||||||
/// context.
|
|
||||||
pub fn get_export(&self, mut store: impl AsContextMut, name: &str) -> Option<Extern> {
|
pub fn get_export(&self, mut store: impl AsContextMut, name: &str) -> Option<Extern> {
|
||||||
self._get_export(&mut store.as_context_mut().opaque(), name)
|
self._get_export(&mut store.as_context_mut().opaque(), name)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user