Skip to content

Commit

Permalink
Mostly fix compatibility with immutable v0.4.0
Browse files Browse the repository at this point in the history
List has to be dropped because type aliases are not allowed for generic types.

There's an outstanding issue that Set can't contain pointer values. benbjohnson/immutable#25

I would abandon this package altogether, but there's no Set type in immutable, and its comparer and hasher types are more boilerplate than I want.
  • Loading branch information
anacrolix committed Oct 26, 2022
1 parent 4f6e80b commit 98fe692
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 78 deletions.
5 changes: 2 additions & 3 deletions external_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func BenchmarkInvertedThunderingHerd(b *testing.B) {
for i := 0; i < b.N; i++ {
done := stm.NewBuiltinEqVar(false)
tokens := stm.NewBuiltinEqVar(0)
pending := stm.NewVar(stmutil.NewSet())
pending := stm.NewVar(stmutil.NewSet[*stm.Var[bool]]())
for range iter.N(1000) {
ready := stm.NewVar(false)
stm.Atomically(stm.VoidOperation(func(tx *stm.Tx) {
Expand Down Expand Up @@ -132,8 +132,7 @@ func BenchmarkInvertedThunderingHerd(b *testing.B) {
for stm.Atomically(func(tx *stm.Tx) bool {
tx.Assert(tokens.Get(tx) > 0)
tokens.Set(tx, tokens.Get(tx)-1)
pending.Get(tx).Range(func(i any) bool {
ready := i.(*stm.Var[bool])
pending.Get(tx).Range(func(ready *stm.Var[bool]) bool {
if !ready.Get(tx) {
ready.Set(tx, true)
return false
Expand Down
19 changes: 11 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ module github.com/anacrolix/stm
go 1.18

require (
github.com/anacrolix/envpprof v1.0.0
github.com/anacrolix/missinggo v1.1.0
github.com/anacrolix/missinggo/v2 v2.2.0
github.com/benbjohnson/immutable v0.2.0
github.com/stretchr/testify v1.3.0
github.com/alecthomas/atomic v0.1.0-alpha2
github.com/anacrolix/envpprof v1.1.0
github.com/anacrolix/missinggo v1.3.0
github.com/anacrolix/missinggo/v2 v2.7.1
github.com/benbjohnson/immutable v0.4.0
github.com/stretchr/testify v1.4.0
golang.org/x/exp v0.0.0-20221026004748-78e5e7837ae6
)

require (
github.com/alecthomas/atomic v0.1.0-alpha2
github.com/bradfitz/iter v0.0.0-20190303215204-33e6a9893b0c // indirect
github.com/anacrolix/log v0.6.0 // indirect
github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/huandu/xstrings v1.2.0 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v2 v2.2.5 // indirect
)
Loading

0 comments on commit 98fe692

Please sign in to comment.