Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
refactored yield() to Fiber.yield(), bumped node-fibers version, upda…
…ted readme.md
  • Loading branch information
Yuriy Bogdanov committed May 4, 2011
1 parent 7761834 commit b21d2eb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
node_modules
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -116,7 +116,8 @@ Transparent integration


Parallel execution: Parallel execution:


var Sync = require('sync'); var Sync = require('sync'),
Future = Sync.Future();


// Run in a fiber // Run in a fiber
Sync(function(){ Sync(function(){
Expand All @@ -137,7 +138,7 @@ Parallel execution:
// Or you can straightly use Sync.Future without wrapper // Or you can straightly use Sync.Future without wrapper
// This call doesn't blocks // This call doesn't blocks
asyncFunction(2, 3, foo = new Sync.Future()); asyncFunction(2, 3, foo = Future());
// foo is a ticket // foo is a ticket
console.log(foo); // { [Function: Future] result: [Getter], error: [Getter] } console.log(foo); // { [Function: Future] result: [Getter], error: [Getter] }
Expand Down
8 changes: 4 additions & 4 deletions lib/sync.js
Expand Up @@ -57,7 +57,7 @@ Function.prototype.sync = function(obj /* arguments */) {
fn.apply(obj || null, args); fn.apply(obj || null, args);


// wait for result // wait for result
while (!cb_args) yield(); while (!cb_args) Fiber.yield();


// err returned as first argument // err returned as first argument
var err = cb_args.shift(); var err = cb_args.shift();
Expand Down Expand Up @@ -203,7 +203,7 @@ function SyncFuture(timeout)
self.ticket(self.timeoutError); self.ticket(self.timeoutError);
}, self.timeout) }, self.timeout)
} }
yield(); Fiber.yield();
} }
if (self._error) throw self._error; if (self._error) throw self._error;
return self._result; return self._result;
Expand Down Expand Up @@ -335,7 +335,7 @@ Sync.Parallel = function SyncParallel(fn)
} }


fn(callback); fn(callback);
while (i > 0) yield(); while (i > 0) Fiber.yield();


return result; return result;
} }
Expand All @@ -354,7 +354,7 @@ Sync.sleep = function(ms)
fiber.run(); fiber.run();
}, ms); }, ms);


yield(); Fiber.yield();
} }


module.exports = exports = Sync; module.exports = exports = Sync;
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -9,6 +9,6 @@
"node": ">=0.3.6" "node": ">=0.3.6"
}, },
"dependencies" : { "dependencies" : {
"fibers": ">=0.2.3" "fibers": ">=0.2.6"
} }
} }

0 comments on commit b21d2eb

Please sign in to comment.