WebAssembly host module, ABI and guest SDK providing atomic data structures suitable for sharing data between concurrent WASI modules.
First register the host module with the runtime
import (
"github.com/tetratelabs/wazero"
"github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1"
"github.com/pantopic/ext-atomic/host-wazero"
)
func main() {
ctx := context.Background()
r := wazero.NewRuntimeWithConfig(ctx, wazero.NewRuntimeConfig())
wasi_snapshot_preview1.MustInstantiate(ctx, r)
module := wazero_atomic.New()
module.Register(ctx, r)
// ...
}Then you can import the guest SDK into your WASI module to send messages from one WASI module to another.
package main
import (
"github.com/pantopic/ext-atomic/sdk-go"
)
var n *atomic.Uint64
func main() {
n = atomic.NewUint64()
}
//export test
func test() {
println(n.Add(1)) // 1
println(n.Add(2)) // 3
}This project is in alpha. Breaking API changes should be expected until Beta.
v0.0.x- Alpha- Stabilize API
v0.x.x- Beta- Finalize API
- Test in production
v1.x.x- General Availability- Proven long term stability in production