remove redundant writers state variable
This commit is contained in:
parent
b83b5405c6
commit
380e16d465
@ -25,7 +25,6 @@ type BadgerMarkSet struct {
|
|||||||
cond sync.Cond
|
cond sync.Cond
|
||||||
pend map[string]struct{}
|
pend map[string]struct{}
|
||||||
writing map[int]map[string]struct{}
|
writing map[int]map[string]struct{}
|
||||||
writers int
|
|
||||||
seqno int
|
seqno int
|
||||||
version int
|
version int
|
||||||
|
|
||||||
@ -236,17 +235,15 @@ func (s *BadgerMarkSet) putPending() error {
|
|||||||
s.seqno++
|
s.seqno++
|
||||||
s.writing[seqno] = pend
|
s.writing[seqno] = pend
|
||||||
s.pend = make(map[string]struct{})
|
s.pend = make(map[string]struct{})
|
||||||
s.writers++
|
|
||||||
s.mx.Unlock()
|
s.mx.Unlock()
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
s.mx.Lock()
|
s.mx.Lock()
|
||||||
defer s.mx.Unlock()
|
defer s.mx.Unlock()
|
||||||
|
|
||||||
delete(s.writing, seqno)
|
|
||||||
s.version++
|
s.version++
|
||||||
s.writers--
|
delete(s.writing, seqno)
|
||||||
if s.writers == 0 {
|
if len(s.writing) == 0 {
|
||||||
s.cond.Broadcast()
|
s.cond.Broadcast()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -278,7 +275,7 @@ func (s *BadgerMarkSet) Close() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
for s.writers > 0 {
|
for len(s.writing) > 0 {
|
||||||
s.cond.Wait()
|
s.cond.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user