package fsmcore import "sync/atomic" type AtomicValue[T any] struct { ptr atomic.Pointer[T] } func NewAtomicValue[T any](val T) *AtomicValue[T] { value := &AtomicValue[T]{} value.ptr.Store(&val) return value } func (v *AtomicValue[T]) Load() (result T) { val := v.ptr.Load() if val == nil { return } return *val } func (v *AtomicValue[T]) Store(value T) { v.ptr.Store(&value) }