Skip to content

Queue.onComplete not return when queue is empty #8

Description

@ductranit

I used queue to wait for all requests finished like this:

var queue = Queue(parallel: 4);
for (final item in items) {
   if(valid(item)) {
        queue.add(() => _sendRequest(item));
   }
}

await queue.onComplete;
print('completed');

For some reasons, if there is no valid item in for loop, the queue is empty. And in this case it pauses at await queue.onComplete forever.
Expect: it should allow to go through next line if queue is empty.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions