Skip to content

Instantly share code, notes, and snippets.

@sranso
Last active March 20, 2017 15:47
Show Gist options
  • Save sranso/32d119645466173db4f8 to your computer and use it in GitHub Desktop.
Save sranso/32d119645466173db4f8 to your computer and use it in GitHub Desktop.

#what is an event loop? this vid

  • JS
    • heap - where mem allocation happens
    • call stack (in chrome it's essentialy v8) - where stack frames are
      • --> look to...
  • web apis - extra things the browser provides
    • dom
    • ajax
    • setTimeout
    • etc
    • --> look to...
  • callback queue
    • onLcick
    • onLoad
    • onDone
  • event loop

###the call stack one thread === one call stack === one thing at a time

  • js is single-threaded programming language
  • can only push off the top, pop off the top
  • 'blowing the stack' -- when you hit max call stack size. ex misused recursion.

###blocking what happens when things are slow?

  • ex three synchronous network requests that are slow, block things after it.
  • blocking is a problem because we're running code in browswers, and we can't do anything in browsers if the call stack has things on it.

###asnchronous callbacks

  • solution for synchronous blocking

###concurrency and the event loop one thing at a time, except not really

  • js can move things from the stack that are 'taking time' and put them in the web api provided by the browser, thereby clearing the stack a little
  • when web apis are done, they push event to task queue
  • event loop's job: look at stack and look at task queue. if stack is empty, it takes first thing on the queue and and pushes it onto the stack which effectively runs it.

liam's notes

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