Duslia opened issue #5774:
I have read the docs. It seems that a store can create multi instances.
<img width="995" alt="image" src="https://user-images.githubusercontent.com/37136584/218698949-9607bab1-a676-4fc1-86a6-8eee0ad0098f.png">
But the interface is defined as follows:pub fn get_typed_func<Params, Results, S>( &self, mut store: S, name: &str, ) -> Result<TypedFunc<Params, Results>>
It cannot be owned by multi instances simultaneously。 So I want to ask if the documentation says that I can build multiple instances with one store, but only one instance can have it at the same time. Does the second instance need to wait until the first instance is executed and released before building the second instance?
Duslia edited issue #5774:
I have read the docs. It seems that a store can create multi instances.
<img width="995" alt="image" src="https://user-images.githubusercontent.com/37136584/218698949-9607bab1-a676-4fc1-86a6-8eee0ad0098f.png">
But the interface is defined as follows:pub fn get_typed_func<Params, Results, S>( &self, mut store: S, name: &str, ) -> Result<TypedFunc<Params, Results>>
store cannot be owned by multi instances simultaneously。 So I want to ask if the documentation says that I can build multiple instances with one store, but only one instance can have it at the same time. Does the second instance need to wait until the first instance is executed and released before building the second instance?
Duslia edited issue #5774:
I have read the docs. It seems that a store can create multi instances.
<img width="995" alt="image" src="https://user-images.githubusercontent.com/37136584/218698949-9607bab1-a676-4fc1-86a6-8eee0ad0098f.png">
But the interface is defined as follows:pub fn get_typed_func<Params, Results, S>( &self, mut store: S, name: &str, ) -> Result<TypedFunc<Params, Results>>
Store cannot be owned by multi instances simultaneously。 So I want to ask if the documentation says that I can build multiple instances with one store, but only one instance can have it at the same time. Does the second instance need to wait until the first instance is executed and released before building the second instance?
alexcrichton commented on issue #5774:
Note that the
S
bound on that function is anAsContextMut
which means you can pass in&mut store
, the API doesn't actually take ownership of the store.You can instantiate many instances within a store, e.g.:
let i1 = linker.instantiate(&mut store, &module1)?; let i2 = linker.instantiate(&mut store, &module2)?;
where here both
i1
andi2
live in the sameStore
.Does that answer your question?
Duslia commented on issue #5774:
emm. But it seems that I cannot execute them asynchronously.
ins.get_typed_func::<(), (), _>(&mut store, &self.method)? .call_async(&mut store, ()) .await?;
Duslia edited a comment on issue #5774:
emm. But it seems that I cannot execute them asynchronously. The second instance needs to wait for the first instance to complete execution.
ins.get_typed_func::<(), (), _>(&mut store, &self.method)? .call_async(&mut store, ()) .await?;
Duslia edited a comment on issue #5774:
emm. But it seems that I cannot execute them asynchronously. The second instance needs to wait for the first instance to complete execution. So I cannot execute two instances with the same store simultaneously.
ins.get_typed_func::<(), (), _>(&mut store, &self.method)? .call_async(&mut store, ()) .await?;
alexcrichton commented on issue #5774:
That's correct, only one asynchronous computation within a store may happen at any one point in time.
Duslia commented on issue #5774:
Ok, I got it. Thanks!
Duslia closed issue #5774:
I have read the docs. It seems that a store can create multi instances.
<img width="995" alt="image" src="https://user-images.githubusercontent.com/37136584/218698949-9607bab1-a676-4fc1-86a6-8eee0ad0098f.png">
But the interface is defined as follows:pub fn get_typed_func<Params, Results, S>( &self, mut store: S, name: &str, ) -> Result<TypedFunc<Params, Results>>
Store cannot be owned by multi instances simultaneously。 So I want to ask if the documentation says that I can build multiple instances with one store, but only one instance can have it at the same time. Does the second instance need to wait until the first instance is executed and released before building the second instance?
Last updated: Nov 22 2024 at 16:03 UTC