finetune view waiting

This commit is contained in:
vyzo 2021-07-13 09:06:40 +03:00
parent 257423e917
commit af399529ec

View File

@ -150,6 +150,7 @@ type SplitStore struct {
txnViewsMx sync.Mutex
txnViewsCond sync.Cond
txnViews int
txnViewsWaiting bool
txnActive bool
txnProtect MarkSet
txnRefsMx sync.Mutex
@ -651,7 +652,7 @@ func (s *SplitStore) viewDone() {
defer s.txnViewsMx.Unlock()
s.txnViews--
if s.txnViews == 0 {
if s.txnViews == 0 && s.txnViewsWaiting {
s.txnViewsCond.Signal()
}
}
@ -660,9 +661,11 @@ func (s *SplitStore) viewWait() {
s.txnViewsMx.Lock()
defer s.txnViewsMx.Unlock()
s.txnViewsWaiting = true
for s.txnViews > 0 {
s.txnViewsCond.Wait()
}
s.txnViewsWaiting = false
}
// transactionally protect a reference to an object