MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime-go / NewStoreWithData

Function NewStoreWithData

store.go:76–93  ·  view source on GitHub ↗

NewStoreWithData creates a new [Store] from engine and associates data with it. Embedders can access data via [Storelike.Data]

(engine *Engine, data interface{})

Source from the content-addressed store, hash-verified

74// NewStoreWithData creates a new [Store] from engine and associates data with it.
75// Embedders can access data via [Storelike.Data]
76func NewStoreWithData(engine *Engine, data interface{}) *Store {
77 // Allocate an index for this store and allocate some internal data to go with
78 // the store.
79 gStoreLock.Lock()
80 idx := gStoreSlab.allocate()
81 gStoreMap[idx] = &storeData{engine: engine, data: data}
82 gStoreLock.Unlock()
83
84 ptr := C.go_store_new(engine.ptr(), C.size_t(idx))
85 store := &Store{
86 _ptr: ptr,
87 Engine: engine,
88 }
89 runtime.SetFinalizer(store, func(store *Store) {
90 store.Close()
91 })
92 return store
93}
94
95//export goFinalizeStore
96func goFinalizeStore(env unsafe.Pointer) {

Callers 3

TestLinkerFuncsFunction · 0.85
NewStoreFunction · 0.85
TestStoreDataFunction · 0.85

Calls 3

CloseMethod · 0.95
allocateMethod · 0.80
ptrMethod · 0.45

Tested by 2

TestLinkerFuncsFunction · 0.68
TestStoreDataFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…