example: anonymous module in concurrent instantiation (#1338)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
|||||||
_ "embed"
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/tetratelabs/wazero"
|
"github.com/tetratelabs/wazero"
|
||||||
@@ -41,12 +40,8 @@ func main() {
|
|||||||
go func(i int) {
|
go func(i int) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
// Important: each instance needs a unique "name", so we create new wazero.ModuleConfig per instance,
|
|
||||||
// and assigns the iteration counter as the name.
|
|
||||||
config := wazero.NewModuleConfig().WithName(strconv.Itoa(i))
|
|
||||||
|
|
||||||
// Instantiate a new Wasm module from the already compiled `compiledWasm`.
|
// Instantiate a new Wasm module from the already compiled `compiledWasm`.
|
||||||
instance, err := r.InstantiateModule(ctx, compiledWasm, config)
|
instance, err := r.InstantiateModule(ctx, compiledWasm, wazero.NewModuleConfig().WithName(""))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicf("[%d] failed to instantiate %v", i, err)
|
log.Panicf("[%d] failed to instantiate %v", i, err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user