Permalink
Browse files

Worker sample updated

  • Loading branch information...
1 parent 456e5c9 commit 8b2bd09018ceeeaf2c818040083c8edba3f77ec2 @ajlopez committed Feb 3, 2013
Showing with 7 additions and 2 deletions.
  1. +5 −0 samples/worker/README.md
  2. +2 −2 samples/worker/server.js
View
@@ -36,3 +36,8 @@ The worker output:
{ a: { count: 2 }, word: { count: 2 }, is: { count: 1 } }
```
+The implementation is naive. It uses `next` callbacks but without async calls in `map` or `process`.
+If there were thousands of items or key/values produced by `map`, this approach would generate
+a lot of stacked calls.
+
+
View
@@ -5,9 +5,9 @@ var simplemessages = require('simplemessages'),
var task = {
items: ["A", "word", "is", "a", "word"],
getItems: function () { return this.items; },
- map: function (key, value, context) { context.emit(value.toLowerCase(), 1); },
+ map: function (key, value, context, next) { context.emit(value.toLowerCase(), 1); next(); },
newResult: function (key) { return { count: 0 }; },
- process: function (key, value, result) { result.count += value; }
+ process: function (key, value, result, next) { result.count += value; next(); }
};
// To encode functions

0 comments on commit 8b2bd09

Please sign in to comment.