Stream: git-wasmtime

Topic: wasmtime / issue #5774 Is the relationship between store ...


view this post on Zulip Wasmtime GitHub notifications bot (Feb 14 2023 at 09:53):

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?

view this post on Zulip Wasmtime GitHub notifications bot (Feb 14 2023 at 09:53):

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?

view this post on Zulip Wasmtime GitHub notifications bot (Feb 14 2023 at 09:53):

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?

view this post on Zulip Wasmtime GitHub notifications bot (Feb 14 2023 at 15:19):

alexcrichton commented on issue #5774:

Note that the S bound on that function is an AsContextMut 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 and i2 live in the same Store.

Does that answer your question?

view this post on Zulip Wasmtime GitHub notifications bot (Feb 14 2023 at 15:26):

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?;

view this post on Zulip Wasmtime GitHub notifications bot (Feb 14 2023 at 15:27):

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?;

view this post on Zulip Wasmtime GitHub notifications bot (Feb 14 2023 at 15:28):

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?;

view this post on Zulip Wasmtime GitHub notifications bot (Feb 14 2023 at 15:52):

alexcrichton commented on issue #5774:

That's correct, only one asynchronous computation within a store may happen at any one point in time.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 15 2023 at 01:03):

Duslia commented on issue #5774:

Ok, I got it. Thanks!

view this post on Zulip Wasmtime GitHub notifications bot (Feb 15 2023 at 01:03):

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: Dec 23 2024 at 12:05 UTC