View patch
This file contains 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/coroutine.cc b/src/coroutine.cc | |
index f2a0d3d..3c9a8ad 100644 | |
--- a/src/coroutine.cc | |
+++ b/src/coroutine.cc | |
@@ -20,8 +20,6 @@ | |
using namespace std; | |
const size_t v8_tls_keys = 3; | |
-static pthread_key_t floor_thread_key = 0; | |
-static pthread_key_t ceil_thread_key = 0; |
View patch.diff
This file contains 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/coroutine.cc b/src/coroutine.cc | |
index f2a0d3d..64bf201 100644 | |
--- a/src/coroutine.cc | |
+++ b/src/coroutine.cc | |
@@ -20,9 +20,10 @@ | |
using namespace std; | |
const size_t v8_tls_keys = 3; | |
-static pthread_key_t floor_thread_key = 0; | |
-static pthread_key_t ceil_thread_key = 0; |
View repl
This file contains 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
#!/usr/bin/env node | |
"use strict"; | |
var fs = require('fs'); | |
var Future = require('fibers/future'); | |
// Start the repl | |
var vm = require('vm'); | |
var domain = require('domain'); | |
var repl = require('repl').start('node> ', null, fiberEval, true, true); | |
function fiberEval(code, context, file, cb) { |
View body.js
This file contains 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
// Descriptor of a creep body | |
function Body(body) { | |
this.body = body; | |
this._isCreep = typeof body[0] === 'object'; | |
this._cost = undefined; | |
this._weight = undefined; | |
} | |
_.assign(Body.prototype, { |
View sorted.js
This file contains 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 mergeSorted(a, b) { | |
var array = new Array(a.length + b.length); | |
var ii = a.length + b.length - 1; | |
var jj = a.length - 1, kk = b.length - 1; | |
while (jj >= 0 || kk >= 0) { | |
array[ii--] = (jj < 0 || a[jj] < b[kk]) ? b[kk--] : a[jj--]; | |
} | |
return array; | |
} |
View gist:791157
This file contains 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
$ cat adapter.js | |
require('./node-fibers'); | |
var print = require('util').print; | |
// This function runs an asynchronous function from within a fiber as if it | |
// were synchronous. | |
function asyncAsSync(fn /* ... */) { | |
var args = [].slice.call(arguments, 1); | |
var fiber = Fiber.current; |
View earlyfibers.diff
This file contains 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/coroutine.cc b/src/coroutine.cc | |
index e1d8908..265faf4 100644 | |
--- a/src/coroutine.cc | |
+++ b/src/coroutine.cc | |
@@ -42,7 +42,10 @@ static pthread_key_create_t& dyn_pthread_key_create(); | |
* the original implementation but that doesn't work because dlsym() tries to get a lock which ends | |
* up calling pthread_getspecific and pthread_setspecific. So have to implement our own versions of | |
* these functions assuming one thread only and then as soon as we can, put all that saved data into | |
- * real TLS. | |
+ * a better structure. |
View coercion.js
This file contains 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(); | |
}, |
View futures.js
This file contains 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) { |
View future.js
This file contains 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. | |
*/ |
OlderNewer