Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Commit

Permalink
refactored yield() to Fiber.yield(), bumped node-fibers version, upda…
Browse files Browse the repository at this point in the history
…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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ Transparent integration

Parallel execution:

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

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

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

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

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

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

yield();
Fiber.yield();
}

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

0 comments on commit b21d2eb

Please sign in to comment.