Skip to content

Commit

Permalink
data race fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ucwong committed Apr 6, 2023
1 parent ba77dd2 commit a003024
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package shard
import (
"runtime"
"sync"
"sync/atomic"
//"sync/atomic"

//"github.com/cespare/xxhash"
"github.com/tidwall/hashmap"
Expand Down Expand Up @@ -139,16 +139,16 @@ func (m *Map[V]) DeleteAccept(
}

// Len returns the number of values in map.
/*func (m *Map[V]) Len() (length int) {
func (m *Map[V]) Len() (length int) {
for i := 0; i < m.shards; i++ {
m.mus[i].RLock()
length += m.maps[i].Len()
m.mus[i].RUnlock()
}
return
}*/
}

func (m *Map[V]) Len() int {
/*func (m *Map[V]) Len() int {
var length atomic.Int32
var wg sync.WaitGroup
Expand All @@ -162,7 +162,7 @@ func (m *Map[V]) Len() int {
}
wg.Wait()
return int(length.Load())
}
}*/

// Range calls the provided callback function for each key-value pair in the map until the
// callback returns false or all pairs have been processed.
Expand Down

0 comments on commit a003024

Please sign in to comment.