Skip to content

Instantly share code, notes, and snippets.

@glennblock
Created December 4, 2013 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save glennblock/7783930 to your computer and use it in GitHub Desktop.
Save glennblock/7783930 to your computer and use it in GitHub Desktop.
//fibers
function markComplete(postedItems, completionCallback) {
var errors = [];
var getItemToUpdate = function(item) {
var savedTask;
var fiber = Fiber.current;
process.nextTick(function() {
client.queryEntity('tasks', 'partition1', item, function(err, task) {
savedTask=task;
fiber.run();
});
});
Fiber.yield();
return savedTask;
};
Fiber(function() {
postedItems.forEach(function(item) {
task = getItemToUpdate(item);
console.log(task);
});
completionCallback(undefined);
}).run();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment