use RW mutexes in marksets
This commit is contained in:
parent
48f13a43b7
commit
e6eacbdd56
@ -24,7 +24,7 @@ var _ MarkSetEnv = (*BloomMarkSetEnv)(nil)
|
|||||||
|
|
||||||
type BloomMarkSet struct {
|
type BloomMarkSet struct {
|
||||||
salt []byte
|
salt []byte
|
||||||
mx sync.Mutex
|
mx sync.RWMutex
|
||||||
bf *bbloom.Bloom
|
bf *bbloom.Bloom
|
||||||
ts bool
|
ts bool
|
||||||
}
|
}
|
||||||
@ -84,8 +84,8 @@ func (s *BloomMarkSet) Mark(cid cid.Cid) error {
|
|||||||
|
|
||||||
func (s *BloomMarkSet) Has(cid cid.Cid) (bool, error) {
|
func (s *BloomMarkSet) Has(cid cid.Cid) (bool, error) {
|
||||||
if s.ts {
|
if s.ts {
|
||||||
s.mx.Lock()
|
s.mx.RLock()
|
||||||
defer s.mx.Unlock()
|
defer s.mx.RUnlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.bf == nil {
|
if s.bf == nil {
|
||||||
|
@ -13,7 +13,7 @@ type MapMarkSetEnv struct {
|
|||||||
var _ MarkSetEnv = (*MapMarkSetEnv)(nil)
|
var _ MarkSetEnv = (*MapMarkSetEnv)(nil)
|
||||||
|
|
||||||
type MapMarkSet struct {
|
type MapMarkSet struct {
|
||||||
mx sync.Mutex
|
mx sync.RWMutex
|
||||||
set map[string]struct{}
|
set map[string]struct{}
|
||||||
|
|
||||||
ts bool
|
ts bool
|
||||||
@ -52,8 +52,8 @@ func (s *MapMarkSet) Mark(cid cid.Cid) error {
|
|||||||
|
|
||||||
func (s *MapMarkSet) Has(cid cid.Cid) (bool, error) {
|
func (s *MapMarkSet) Has(cid cid.Cid) (bool, error) {
|
||||||
if s.ts {
|
if s.ts {
|
||||||
s.mx.Lock()
|
s.mx.RLock()
|
||||||
defer s.mx.Unlock()
|
defer s.mx.RUnlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.set == nil {
|
if s.set == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user