This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/binding.gyp b/binding.gyp | |
index 379026f..0413e95 100644 | |
--- a/binding.gyp | |
+++ b/binding.gyp | |
@@ -6,6 +6,7 @@ | |
# Replace gyp platform with node platform, blech | |
['platform == "mac"', {'variables': {'platform': 'darwin'}}], | |
['platform == "win"', {'variables': {'platform': 'win32'}}], | |
+ ['platform == "solaris"', {'variables': {'platform': 'sunos'}}], | |
], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/fibers.cc b/src/fibers.cc | |
index 49a20f7..c446f9d 100644 | |
--- a/src/fibers.cc | |
+++ b/src/fibers.cc | |
@@ -143,6 +143,42 @@ class Fiber { | |
} | |
/** | |
+ * Build a new fiber and immediately run it. | |
+ */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require('path'), | |
fs = require('fs'), | |
Future = require('fibers/future'); | |
// Create future-returning fs functions | |
var fs2 = {}; | |
for (var ii in fs) { | |
fs2[ii] = Future.wrap(fs[ii]); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('fibers'); | |
// Generator function. Returns a function which returns incrementing | |
// Fibonacci numbers with each call. | |
function Fibonacci() { | |
// Create a new fiber which yields sequential Fibonacci numbers | |
var fiber = Fiber(function() { | |
Fiber.yield(0); // F(0) -> 0 | |
var prev = 0, curr = 1; | |
while (true) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
this.MysqlBinlogTailer = MysqlBinlogTailer; | |
var EventEmitter = require('events').EventEmitter; | |
var fs = require('fs'); | |
var path = require('path'); | |
/** | |
* Tails a Mysql binlog and emits an event for every query executed. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Bad third-party code | |
var fs = require('fs'); | |
require('fibers'); | |
function fetchSomething() { // don't do this! | |
var fiber = Fiber.current; | |
fs.readFile(__filename, 'utf8', function(err, val) { | |
fiber.run(val); | |
}); | |
return Fiber.yield(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setTimeout(function() { | |
console.log('timeout'); | |
}, 0); | |
// simulate extreme cpu load | |
var d = +new Date; | |
console.log(new Date); | |
while (d + 2000 > new Date); | |
console.log(new Date); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
require('fibers'); | |
this.Future = Future; | |
this.FiberFuture = FiberFuture; | |
this.wait = wait; | |
/** | |
* Return a function which automatically creates a fiber for each invocation. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Future() {} | |
Future.mixin({ | |
didComplete: function(value) { | |
if (value === undefined) { | |
throw new TypeError('May not return undefined from future'); | |
} | |
this._value = value; | |
var fibers = this._fibers; | |
if (fibers) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.method = function() {} | |
function func(str) {} | |
var stringObject = new String("hello world"); | |
var stringPrimitive = "hello world"; | |
exports.compare = { | |
"stringObject.method()": function() { | |
stringObject.method(); | |
}, |