Skip to content

Instantly share code, notes, and snippets.

@laverdet
laverdet / copy.js
Created February 22, 2011 16:45
compare copying a file natively, and with fibers
require('fibers');
var fs = require('fs');
function resumer() {
var fiber = Fiber.current;
return function(err, val) {
if (err) {
fiber.throwInto(err);
} else {
fiber.run(val);
@laverdet
laverdet / earlyfibers.diff
Created February 4, 2011 19:49
Test patch to fix issue #6 in laverdet/node-fibers
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.
@laverdet
laverdet / gist:791157
Created January 22, 2011 14:39
node-fibers adapter example
$ 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;