0.2.68
This commit is contained in:
@@ -136,6 +136,25 @@ func (q *Queue) Len() int {
|
||||
return len(q.items)
|
||||
}
|
||||
|
||||
// SetLimit applies an operator change immediately. The strongest candidates survive a
|
||||
// reduction, using the same ordering as Claim, so changing the setting cannot reshuffle
|
||||
// the meaning of priority.
|
||||
func (q *Queue) SetLimit(limit int) {
|
||||
if limit <= 0 {
|
||||
return
|
||||
}
|
||||
q.mu.Lock()
|
||||
defer q.mu.Unlock()
|
||||
q.limit = limit
|
||||
for len(q.items) > q.limit {
|
||||
weakestID, _ := q.weakestLocked()
|
||||
if weakestID == "" {
|
||||
break
|
||||
}
|
||||
delete(q.items, weakestID)
|
||||
}
|
||||
}
|
||||
|
||||
// Snapshot is the queue in worker order, for the log line and the admin console.
|
||||
func (q *Queue) Snapshot() []Candidate {
|
||||
q.mu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user