enqueue adds the key to the workQ if it is not already pending.
(keys ...K)
| 1517 | |
| 1518 | // enqueue adds the key to the workQ if it is not already pending. |
| 1519 | func (q *workQ[K]) enqueue(keys ...K) { |
| 1520 | q.cond.L.Lock() |
| 1521 | defer q.cond.L.Unlock() |
| 1522 | for _, key := range keys { |
| 1523 | if slices.Contains(q.pending, key) { |
| 1524 | continue |
| 1525 | } |
| 1526 | q.pending = append(q.pending, key) |
| 1527 | } |
| 1528 | q.cond.Signal() |
| 1529 | } |
| 1530 | |
| 1531 | // acquireBatch blocks until at least one pending key is available, then |
| 1532 | // returns up to limit keys, moving them to inProgress. Caller must call |