in pq/buffer.go [205:242]
func (b *buffer) Pages() (start, end *page, n uint) {
traceln("get buffer active page range")
if b.head == nil || !b.head.Dirty() {
traceln("buffer empty")
return nil, nil, 0
}
if b.eventHdrPage == nil {
traceln("no active page")
if b.tail.Dirty() {
traceln("tail is dirty")
return b.head, nil, b.countPages
}
traceln("tail is not dirty")
for current := b.head; current != nil; current = current.Next {
if !current.Dirty() {
return b.head, current, n
}
n++
}
invariant.Unreachable("tail if list dirty and not dirty?")
}
end = b.eventHdrPage
n = b.countPages
if end.Dirty() {
traceln("active page is dirty")
end = end.Next
} else {
traceln("active page is clean")
n--
}
return b.head, end, n
}