aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bench_test.go8
-rw-r--r--cmd/santa-example/main.go8
-rw-r--r--doc_test.go2
-rw-r--r--external_test.go4
-rw-r--r--rate/ratelimit.go4
-rw-r--r--stm_test.go22
-rw-r--r--stmutil/context.go2
7 files changed, 25 insertions, 25 deletions
diff --git a/bench_test.go b/bench_test.go
index 0b84715..0d40caf 100644
--- a/bench_test.go
+++ b/bench_test.go
@@ -8,14 +8,14 @@ import (
)
func BenchmarkAtomicGet(b *testing.B) {
- x := NewVar[int](0)
+ x := NewVar(0)
for i := 0; i < b.N; i++ {
AtomicGet(x)
}
}
func BenchmarkAtomicSet(b *testing.B) {
- x := NewVar[int](0)
+ x := NewVar(0)
for i := 0; i < b.N; i++ {
AtomicSet(x, 0)
}
@@ -24,7 +24,7 @@ func BenchmarkAtomicSet(b *testing.B) {
func BenchmarkIncrementSTM(b *testing.B) {
for i := 0; i < b.N; i++ {
// spawn 1000 goroutines that each increment x by 1
- x := NewVar[int](0)
+ x := NewVar(0)
for i := 0; i < 1000; i++ {
go Atomically(VoidOperation(func(tx *Tx) {
cur := x.Get(tx)
@@ -83,7 +83,7 @@ func BenchmarkReadVarSTM(b *testing.B) {
for i := 0; i < b.N; i++ {
var wg sync.WaitGroup
wg.Add(1000)
- x := NewVar[int](0)
+ x := NewVar(0)
for i := 0; i < 1000; i++ {
go func() {
AtomicGet(x)
diff --git a/cmd/santa-example/main.go b/cmd/santa-example/main.go
index 1a93ae4..dcc8067 100644
--- a/cmd/santa-example/main.go
+++ b/cmd/santa-example/main.go
@@ -64,7 +64,7 @@ func (g gate) operate() {
func newGate(capacity int) gate {
return gate{
capacity: capacity,
- remaining: stm.NewVar[int](0), // gate starts out closed
+ remaining: stm.NewVar(0), // gate starts out closed
}
}
@@ -77,9 +77,9 @@ type group struct {
func newGroup(capacity int) *group {
return &group{
capacity: capacity,
- remaining: stm.NewVar[int](capacity), // group starts out with full capacity
- gate1: stm.NewVar[gate](newGate(capacity)),
- gate2: stm.NewVar[gate](newGate(capacity)),
+ remaining: stm.NewVar(capacity), // group starts out with full capacity
+ gate1: stm.NewVar(newGate(capacity)),
+ gate2: stm.NewVar(newGate(capacity)),
}
}
diff --git a/doc_test.go b/doc_test.go
index 670d07b..ae1af9a 100644
--- a/doc_test.go
+++ b/doc_test.go
@@ -6,7 +6,7 @@ import (
func Example() {
// create a shared variable
- n := stm.NewVar[int](3)
+ n := stm.NewVar(3)
// read a variable
var v int
diff --git a/external_test.go b/external_test.go
index d0f5ecf..201712d 100644
--- a/external_test.go
+++ b/external_test.go
@@ -99,9 +99,9 @@ func BenchmarkInvertedThunderingHerd(b *testing.B) {
for i := 0; i < b.N; i++ {
done := stm.NewBuiltinEqVar(false)
tokens := stm.NewBuiltinEqVar(0)
- pending := stm.NewVar[stmutil.Settish](stmutil.NewSet())
+ pending := stm.NewVar(stmutil.NewSet())
for range iter.N(1000) {
- ready := stm.NewVar[bool](false)
+ ready := stm.NewVar(false)
stm.Atomically(stm.VoidOperation(func(tx *stm.Tx) {
pending.Set(tx, pending.Get(tx).Add(ready))
}))
diff --git a/rate/ratelimit.go b/rate/ratelimit.go
index 7fde1ce..6645e04 100644
--- a/rate/ratelimit.go
+++ b/rate/ratelimit.go
@@ -36,9 +36,9 @@ func Every(interval time.Duration) Limit {
func NewLimiter(rate Limit, burst numTokens) *Limiter {
rl := &Limiter{
- max: stm.NewVar[int](burst),
+ max: stm.NewVar(burst),
cur: stm.NewBuiltinEqVar(burst),
- lastAdd: stm.NewVar[time.Time](time.Now()),
+ lastAdd: stm.NewVar(time.Now()),
rate: rate,
}
if rate != Inf {
diff --git a/stm_test.go b/stm_test.go
index 4103563..8726d40 100644
--- a/stm_test.go
+++ b/stm_test.go
@@ -11,7 +11,7 @@ import (
)
func TestDecrement(t *testing.T) {
- x := NewVar[int](1000)
+ x := NewVar(1000)
for i := 0; i < 500; i++ {
go Atomically(VoidOperation(func(tx *Tx) {
cur := x.Get(tx)
@@ -35,7 +35,7 @@ func TestDecrement(t *testing.T) {
// read-only transaction aren't exempt from calling tx.inputsChanged
func TestReadVerify(t *testing.T) {
read := make(chan struct{})
- x, y := NewVar[int](1), NewVar[int](2)
+ x, y := NewVar(1), NewVar(2)
// spawn a transaction that writes to x
go func() {
@@ -61,7 +61,7 @@ func TestReadVerify(t *testing.T) {
}
func TestRetry(t *testing.T) {
- x := NewVar[int](10)
+ x := NewVar(10)
// spawn 10 transactions, one every 10 milliseconds. This will decrement x
// to 0 over the course of 100 milliseconds.
go func() {
@@ -93,7 +93,7 @@ func TestVerify(t *testing.T) {
type foo struct {
i int
}
- x := NewVar[*foo](&foo{3})
+ x := NewVar(&foo{3})
read := make(chan struct{})
// spawn a transaction that modifies x
@@ -128,14 +128,14 @@ func TestSelect(t *testing.T) {
require.Panics(t, func() { Atomically(Select[struct{}]()) })
// with one arg, Select adds no effect
- x := NewVar[int](2)
+ x := NewVar(2)
Atomically(Select(VoidOperation(func(tx *Tx) {
tx.Assert(x.Get(tx) == 2)
})))
picked := Atomically(Select(
// always blocks; should never be selected
- func(tx *Tx)int {
+ func(tx *Tx) int {
tx.Retry()
panic("unreachable")
},
@@ -179,7 +179,7 @@ func TestPanic(t *testing.T) {
func TestReadWritten(t *testing.T) {
// reading a variable written in the same transaction should return the
// previously written value
- x := NewVar[int](3)
+ x := NewVar(3)
Atomically(VoidOperation(func(tx *Tx) {
x.Set(tx, 5)
tx.Assert(x.Get(tx) == 5)
@@ -188,7 +188,7 @@ func TestReadWritten(t *testing.T) {
func TestAtomicSetRetry(t *testing.T) {
// AtomicSet should cause waiting transactions to retry
- x := NewVar[int](3)
+ x := NewVar(3)
done := make(chan struct{})
go func() {
Atomically(VoidOperation(func(tx *Tx) {
@@ -207,9 +207,9 @@ func TestAtomicSetRetry(t *testing.T) {
func testPingPong(t testing.TB, n int, afterHit func(string)) {
ball := NewBuiltinEqVar(false)
- doneVar := NewVar[bool](false)
- hits := NewVar[int](0)
- ready := NewVar[bool](true) // The ball is ready for hitting.
+ doneVar := NewVar(false)
+ hits := NewVar(0)
+ ready := NewVar(true) // The ball is ready for hitting.
var wg sync.WaitGroup
bat := func(from, to bool, noise string) {
defer wg.Done()
diff --git a/stmutil/context.go b/stmutil/context.go
index 9d23e12..6f8ba9b 100644
--- a/stmutil/context.go
+++ b/stmutil/context.go
@@ -26,7 +26,7 @@ func ContextDoneVar(ctx context.Context) (*stm.Var[bool], func()) {
v := stm.NewBuiltinEqVar(true)
return v, func() {}
}
- v := stm.NewVar[bool](false)
+ v := stm.NewVar(false)
go func() {
<-ctx.Done()
stm.AtomicSet(v, true)