acquire blocks until a work item is available and returns it. After acquiring a key, the worker MUST call done() with the same key to mark it complete and allow new pending work to be acquired for the key.
()
| 1565 | // acquiring a key, the worker MUST call done() with the same key to mark |
| 1566 | // it complete and allow new pending work to be acquired for the key. |
| 1567 | func (q *workQ[K]) acquire() (key K, err error) { |
| 1568 | items, err := q.acquireBatch(1) |
| 1569 | if err != nil { |
| 1570 | return key, err |
| 1571 | } |
| 1572 | return items[0], nil |
| 1573 | } |
| 1574 | |
| 1575 | // done marks the key completed; MUST be called after acquire() for each key. |
| 1576 | func (q *workQ[K]) done(keys ...K) { |