2024-04-10 13:15:36 +01:00
|
|
|
package util
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
|
|
|
|
"github.com/tetratelabs/wazero/experimental"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type moduleKey struct{}
|
|
|
|
|
type moduleState struct {
|
|
|
|
|
mmapState
|
2024-04-28 10:33:39 +01:00
|
|
|
handleState
|
2024-04-10 13:15:36 +01:00
|
|
|
}
|
|
|
|
|
|
2024-04-26 16:25:45 +01:00
|
|
|
func NewContext(ctx context.Context) context.Context {
|
2024-04-10 13:15:36 +01:00
|
|
|
state := new(moduleState)
|
2024-05-17 16:42:43 +01:00
|
|
|
ctx = withAllocator(ctx)
|
2024-04-10 13:15:36 +01:00
|
|
|
ctx = experimental.WithCloseNotifier(ctx, state)
|
2024-04-26 16:25:45 +01:00
|
|
|
ctx = context.WithValue(ctx, moduleKey{}, state)
|
2024-04-10 13:15:36 +01:00
|
|
|
return ctx
|
|
|
|
|
}
|