title: Why do Promise libraries use event loops?
body: <p>Considering the following JavaScript code:</p>
  
  <pre><code>var promise = new Promise();
  setTimeout(function() {
      promise.resolve();
  }, 10);
  
  function foo() { }
  promise.then(foo);
  </code></pre>
  
  <p>In the promise implementations I've seen, promise.resolve() would simply set some property to indicate the promise was resolved and foo() would be called later during an event loop, yet it seems like the promise.resolve() would have enough information to immediately call any deferred functions such as foo().</p>
  
  <p>The event loop method seems like it would add complexity and reduce performance, so why is it used?</p>
  
  <p>While most of my use of promises is with JavaScript, part of the reason for my question is in implementing promises in very performance intensive cases like C++ games, in which case I'm wondering if I could utilize some of the benefits of promises without the overhead of an event loop.</p>