Skip to content

Instantly share code, notes, and snippets.

@cjhanks
Created March 20, 2013 19:11
Show Gist options
  • Save cjhanks/5207545 to your computer and use it in GitHub Desktop.
Save cjhanks/5207545 to your computer and use it in GitHub Desktop.
JS loop
Slot.prototype.poll = function () {
/* This polls infinitely for new work in the queue and if they become
* available properly routes the input into execution.
*
* Note that is very important to be careful to call semantics in this
* function to prevent stack overflow.
*/
var self = this;
self['swf'].pollForActivityTask(self['aws_opts'], function (err, res) {
if (err)
self.emit('exception', err);
if (null == res || !res.taskToken)
self.poll();
else
self.exec(res, function () { self.poll(); });
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment