aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2025-05-22 13:09:35 -0300
committerEuAndreh <eu@euandre.org>2025-05-22 13:09:35 -0300
commit70fe6f1cbb448b473eeda4d5ef7f3ac6630dd8d7 (patch)
treed9bbff162eef59317a01e1369736206e3c3d3ae1
parentsrc/stm.go: Remove ad-hoc profiling code (diff)
downloadstm-70fe6f1cbb448b473eeda4d5ef7f3ac6630dd8d7.tar.gz
stm-70fe6f1cbb448b473eeda4d5ef7f3ac6630dd8d7.tar.xz
src/stm.go: Rename Interface -> atomicI
-rw-r--r--src/stm.go8
-rw-r--r--tests/benchmarks/interface-store/stm.go2
2 files changed, 5 insertions, 5 deletions
diff --git a/src/stm.go b/src/stm.go
index 41359af..6aa6fae 100644
--- a/src/stm.go
+++ b/src/stm.go
@@ -102,7 +102,7 @@ import (
// the type.
// Interface represents atomic operations on a value.
-type Interface[T any] interface {
+type atomicI[T any] interface{
// Load value atomically.
Load() T
// Store value atomically.
@@ -113,7 +113,7 @@ type Interface[T any] interface {
CompareAndSwap(old, new T) (swapped bool)
}
-var _ Interface[bool] = &Value[bool]{}
+var _ atomicI[bool] = &Value[bool]{}
// Value wraps any generic value in atomic load and store operations.
//
@@ -150,7 +150,7 @@ type atomicint interface {
// Int expresses atomic operations on signed or unsigned integer values.
type Int[T atomicint] interface {
- Interface[T]
+ atomicI[T]
// Add a value and return the new result.
Add(delta T) (new T)
}
@@ -399,7 +399,7 @@ func VoidOperation(f func(*Tx)) Operation[struct{}] {
}
}
-func Swap[T any](v *Var[T], f func(T) T) {
+func Swap[T any](v *AtomT[T], f func(T) T) {
Atomically(VoidOperation(func(tx *Tx) {
v.Set(tx, f(v.Get(tx)))
}))
diff --git a/tests/benchmarks/interface-store/stm.go b/tests/benchmarks/interface-store/stm.go
index 8e9a36b..167f448 100644
--- a/tests/benchmarks/interface-store/stm.go
+++ b/tests/benchmarks/interface-store/stm.go
@@ -17,7 +17,7 @@ func MainTest() {
flag.Parse()
n := *nFlag
- var v Interface[string] = New("hello")
+ var v atomicI[string] = New("hello")
for i := 0; i < n; i++ {
v.Store(fmt.Sprint(i))
}