Skip to content

Commit fb1dd4f

Browse files
moritzmoekstiehl
authored andcommitted
add comments
Co-authored-by: kstiehl <[email protected]>
1 parent 5f2c4ea commit fb1dd4f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/controller/priorityqueue/priorityqueue.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ func (w *priorityqueue[T]) spin() {
231231
var toDelete []*item[T]
232232

233233
var key T
234+
235+
// Items in the queue tree are sorted first by priority and second by readiness, so
236+
// items with a lower priority might be ready further down in the queue.
237+
// In search for ready items we use the pivot item to skip through priorities without ascending the whole tree.
234238
pivot := item[T]{
235239
Key: key,
236240
AddedCounter: 0,
@@ -254,6 +258,7 @@ func (w *priorityqueue[T]) spin() {
254258
nextItemReadyAt = *item.ReadyAt
255259
}
256260

261+
// Adjusting the pivot item moves the ascend to the next lower priority
257262
pivot.Priority = item.Priority - 1
258263
pivotChange = true
259264
return false

0 commit comments

Comments
 (0)