Skip to content
This repository has been archived by the owner on Feb 25, 2020. It is now read-only.

Commit

Permalink
spaw returns fiber
Browse files Browse the repository at this point in the history
  • Loading branch information
olegp committed Sep 22, 2013
1 parent 13f6946 commit 07c2476
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ exports.exit = function(status) {
* callback The callback to call.
*/
exports.onexit = function(callback) {
process.on('SIGINT', spawn(callback));
process.on('SIGINT', function() {
spawn(callback);
});
};

/**
Expand All @@ -79,13 +81,15 @@ exports.onexit = function(callback) {
*/
var spawn = exports.spawn = function(run) {
// TODO bring in line with RingoJS
return Fiber(function() {
var fiber = Fiber(function() {
try {
run();
} catch (e) {
console.error(e.stack);
}
}).run();
});
fiber.run();
return fiber;
};

exports.parallel = function(fibers) {
Expand Down

0 comments on commit 07c2476

Please sign in to comment.