X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/f5c601f1801aaa276f8c335fcb51c373edc0b50c..fc0503be49438775c5d08499046852df59bd7377:/build_queue.go diff --git a/build_queue.go b/build_queue.go index 540e396..825277c 100644 --- a/build_queue.go +++ b/build_queue.go @@ -82,6 +82,18 @@ func (q *BuildQueue) Next() (NodeKey, bool) { return leaf, found } +// nextLeaf returns the oldest leaf in the window that can start. +func (q *BuildQueue) nextLeaf() (NodeKey, bool) { + for _, id := range q.leaves[:min(len(q.leaves), buildLeafWindow)] { + key := NodeKey{0, id} + if !q.running[key] && !q.failed[key] { + return key, true + } + } + + return NodeKey{}, false +} + // Done removes a built node from the queue. func (q *BuildQueue) Done(key NodeKey) { delete(q.running, key) @@ -126,18 +138,6 @@ func (q *BuildQueue) Running() int { return len(q.running) } -// nextLeaf returns the oldest leaf in the window that can start. -func (q *BuildQueue) nextLeaf() (NodeKey, bool) { - for _, id := range q.leaves[:min(len(q.leaves), buildLeafWindow)] { - key := NodeKey{0, id} - if !q.running[key] && !q.failed[key] { - return key, true - } - } - - return NodeKey{}, false -} - func (h BuildMergeHeap) Len() int { return len(h) }