Lower CPU usage at idle by reducing db polling

This commit is contained in:
Jakob Borg
2014-06-20 00:27:54 +02:00
parent 0e59b5678a
commit efbdf72d20
4 changed files with 49 additions and 5 deletions

View File

@@ -872,3 +872,18 @@ func (m *Model) Override(repo string) {
r.Update(cid.LocalID, fs)
}
// Version returns the change version for the given repository. This is
// guaranteed to increment if the contents of the local or global repository
// has changed.
func (m *Model) Version(repo string) uint64 {
var ver uint64
m.rmut.Lock()
for _, n := range m.repoNodes[repo] {
ver += m.repoFiles[repo].Changes(m.cm.Get(n))
}
m.rmut.Unlock()
return ver
}