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

I don't get the non-blocking description #42

Open
johnyradio opened this issue Jan 2, 2016 · 2 comments
Open

I don't get the non-blocking description #42

johnyradio opened this issue Jan 2, 2016 · 2 comments

Comments

@johnyradio
Copy link

Hi, i don't get the section on non-blocking code. You say a must complete it's task before it calls b -- to me, that sounds like a is blocking b. I thought asynchronous means two threads of code, a and b, getting executing simultaneously, not first a, then b. Or that b can begin before a is finished. -thx

@benjick
Copy link

benjick commented Jan 15, 2016

A is blocking b because you want to use the result of a inside b. Nothing else is blocked and other script can execute

@jGlass314
Copy link

I think this section needs some work. The only reason this is non-blocking is because a() calls another function download that defines a function with the callback to b(). The description however implies you could define a() simply as:

function a(done) {
  done();
};

and execution would be asynchronous.

However, if a() were defined this way and you called functions:

a(b);
c();

then c() wouldn't get called until b() finished inside of a(), and a() would block c()'s execution after all.

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

3 participants