Reorganize the lock to make the comment more explanatory.

This commit is contained in:
M. J. Fromberger
2022-02-18 12:12:35 -08:00
parent 70e6b29dbe
commit 1009104ab4

View File

@@ -72,10 +72,10 @@ func (lg *Log) Add(etype string, data types.EventData) error {
lg.updateHead(head)
size := lg.numItems
age := head.item.Cursor.Diff(lg.oldestCursor)
lg.mu.Unlock()
// If the log requires pruning, do the pruning step outside the lock. This
// permits readers to continue to make progress while we're working.
lg.mu.Unlock()
return lg.checkPrune(head, size, age)
}