finetune view waiting
This commit is contained in:
parent
257423e917
commit
af399529ec
@ -146,15 +146,16 @@ type SplitStore struct {
|
|||||||
debug *debugLog
|
debug *debugLog
|
||||||
|
|
||||||
// transactional protection for concurrent read/writes during compaction
|
// transactional protection for concurrent read/writes during compaction
|
||||||
txnLk sync.RWMutex
|
txnLk sync.RWMutex
|
||||||
txnViewsMx sync.Mutex
|
txnViewsMx sync.Mutex
|
||||||
txnViewsCond sync.Cond
|
txnViewsCond sync.Cond
|
||||||
txnViews int
|
txnViews int
|
||||||
txnActive bool
|
txnViewsWaiting bool
|
||||||
txnProtect MarkSet
|
txnActive bool
|
||||||
txnRefsMx sync.Mutex
|
txnProtect MarkSet
|
||||||
txnRefs map[cid.Cid]struct{}
|
txnRefsMx sync.Mutex
|
||||||
txnMissing map[cid.Cid]struct{}
|
txnRefs map[cid.Cid]struct{}
|
||||||
|
txnMissing map[cid.Cid]struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ bstore.Blockstore = (*SplitStore)(nil)
|
var _ bstore.Blockstore = (*SplitStore)(nil)
|
||||||
@ -651,7 +652,7 @@ func (s *SplitStore) viewDone() {
|
|||||||
defer s.txnViewsMx.Unlock()
|
defer s.txnViewsMx.Unlock()
|
||||||
|
|
||||||
s.txnViews--
|
s.txnViews--
|
||||||
if s.txnViews == 0 {
|
if s.txnViews == 0 && s.txnViewsWaiting {
|
||||||
s.txnViewsCond.Signal()
|
s.txnViewsCond.Signal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -660,9 +661,11 @@ func (s *SplitStore) viewWait() {
|
|||||||
s.txnViewsMx.Lock()
|
s.txnViewsMx.Lock()
|
||||||
defer s.txnViewsMx.Unlock()
|
defer s.txnViewsMx.Unlock()
|
||||||
|
|
||||||
|
s.txnViewsWaiting = true
|
||||||
for s.txnViews > 0 {
|
for s.txnViews > 0 {
|
||||||
s.txnViewsCond.Wait()
|
s.txnViewsCond.Wait()
|
||||||
}
|
}
|
||||||
|
s.txnViewsWaiting = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// transactionally protect a reference to an object
|
// transactionally protect a reference to an object
|
||||||
|
Loading…
Reference in New Issue
Block a user