Created
November 22, 2015 17:08
-
-
Save awilson28/ce9497779e7242df25c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// `eventQueue` is an array that acts as a queue (first-in, first-out) | |
var eventQueue = [ ]; | |
var event; | |
// the event loop keeps going "forever" | |
while (true) { | |
// perform a "tick" | |
if (eventQueue.length > 0) { | |
// get the next event in the queue | |
event = eventQueue.shift(); | |
// now, execute the next event | |
try { | |
event(); | |
} | |
catch (err) { | |
reportError(err); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment