Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

complete conditions before call queue.drain() #668

Closed
wants to merge 1 commit into from
Closed

complete conditions before call queue.drain() #668

wants to merge 1 commit into from

Conversation

jinchan-ck
Copy link

code in async.queue:

if(data.length == 0) {
  // call drain immediately if there are no tasks
  return async.setImmediate(function() {
    if (q.drain) {
      q.drain();
    }
  });
}

If param data is [], q.drain() will be called, but the q.tasks and workers may not be empty.
So I added a condition, made it like this:

if(data.length === 0 && q.idle()) {
  // call drain immediately if there are no tasks
  return async.setImmediate(function() {
    if (q.drain) {
      q.drain();
    }
  });
}

@yorkie
Copy link

yorkie commented Nov 25, 2014

wow~ amazing +1 🍒

@@ -742,7 +742,7 @@
if (!_isArray(data)) {
data = [data];
}
if(data.length == 0) {
if(data.length === 0 && q.idle()) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep coding style consistent, I think we should fix this btw:
if (data.length === 0 && q.idle()) {

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

Successfully merging this pull request may close these issues.

None yet

3 participants