title: Where is the node.js event queue?
body: <p>I have seen similar questions on stack overflow but none of them fully dive down into the question that I have? I am familiar with event queues, how they work as well as implementing them. I am new to node.js and I am trying to wrap my head around how Node.js does it.</p>
  
  <p>In a c++ application you would do something along the lines of:</p>
  
  <pre><code>int main(){
      std::vector&lt;Handler*&gt; handlers;
      BlockingQueue queue = new BlockingQueue();
      //Add all the handlers call constructors and other such initialization
  
      //Then run the event loop
      while(true){
          Event e = queue.pop();
  
          for( std::vector&lt;Handler&gt;::iterator it = handlers.begin(); it != handlers.end(); ++it){
              *it.handle(e);
           }
       }
  }
  </code></pre>
  
  <p>Now in the case of node.js I might have a main file called main.js that looks like.</p>
  
  <pre><code>var http = require("http");
  function main(){
      // Console will print the message
      console.log('Server running at http://127.0.0.1:8080/');
      var server = http.createServer(function (request, response) {
  
          // Send the HTTP header
          // HTTP Status: 200 : OK
          // Content Type: text/plain
          response.writeHead(200, {'Content-Type': 'text/plain'});
  
          // Send the response body as "Hello World"
          response.end('Hello World\n');
      });
  
      server.listen(8080);
      console.log('Main completed');
  }
  
  main();
  </code></pre>
  
  <p>I understand the server.listen is attaching a handler to the event queue and that we are adding the callback similar to the c++ example. </p>
  
  <p>My question is. Where is the event queue? Is it in the javascript somewhere or is it built into the interpreter? Also how does the main function get called relative to the main event loop?</p>