Created
April 2, 2015 20:53
-
-
Save wtfaremyinitials/b13771a80b963eae77fb to your computer and use it in GitHub Desktop.
Generator function tasks
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
var MiningTask = function* MiningTask() { | |
for(var i=0; i<5; i++) { | |
yield breakBlock(); | |
} | |
} | |
var tasks = []; | |
tasks.push(MiningTask()); | |
var tick = function() { | |
var task = tasks.pop(); | |
var r = task.next(); | |
if(!r.done) | |
tasks.push(r); | |
process.nextTick(tick); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment