This commit is contained in:
alex.sharov 2023-04-19 12:19:20 +07:00
parent 3b66aa0571
commit 94770020ec

View File

@ -316,6 +316,15 @@ func (q *ResultsQueueIter) PopNext() *TxTask {
}
func (q *ResultsQueue) Drain(ctx context.Context) error {
q.Lock()
l := q.results.Len()
q.Unlock()
// if queue is empty, then need block to wait new results
if l > 0 {
q.drainNoBlock(nil)
return nil
}
select {
case <-ctx.Done():
return ctx.Err()