aboutsummaryrefslogtreecommitdiff
path: root/var.go
diff options
context:
space:
mode:
Diffstat (limited to 'var.go')
-rw-r--r--var.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/var.go b/var.go
index 2d0cb21..51160e2 100644
--- a/var.go
+++ b/var.go
@@ -1,6 +1,7 @@
package stm
import (
+ "sync"
"sync/atomic"
"unsafe"
)
@@ -8,7 +9,8 @@ import (
// Holds an STM variable.
type Var struct {
state *varSnapshot
- watchers map[*Tx]struct{}
+ watchers sync.Map
+ mu sync.Mutex
}
func (v *Var) addr() *unsafe.Pointer {
@@ -35,6 +37,5 @@ func NewVar(val interface{}) *Var {
state: &varSnapshot{
val: val,
},
- watchers: make(map[*Tx]struct{}),
}
}