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

Question on collectFilesToInject function #79

Closed
dman777 opened this issue Jan 11, 2015 · 1 comment
Closed

Question on collectFilesToInject function #79

dman777 opened this issue Jan 11, 2015 · 1 comment

Comments

@dman777
Copy link

dman777 commented Jan 11, 2015

I was studying your code for learning purposes. In collectFilesToInject, why do you use process.nextTick in:

  function resolve (cb) {
    process.nextTick(function () {
      cb(collection);
    });
  }

I ask this because with while (queue.length) { resolve(queue.shift()); }, it will throw these non blocking jobs on the Queue and each one will run async since I/O operations are natively non-blocking, This would be done without process.nextTick(). However, since we are using process.nextTick()...which is blocking(in contrast to setImmediate()), doesn't this defeat async nature?

@joakimbeng
Copy link
Member

@dman777 I see. I guess I haven't read enough about those functions to understand the difference between them. Now when I have, I agree with you that setImmediate() should be used instead.

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

No branches or pull requests

2 participants