Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Support for node v0.11.3

The v8 API is a moving target, isn't it? Closes gh-123.
  • Loading branch information...
commit 982f50cd648bb85700c0a295576579f117a58ebb 1 parent a6d3c66
@laverdet authored
View
23 src/fibers.cc
@@ -34,9 +34,14 @@ namespace uni {
handle.Dispose(isolate);
}
- template <void (*F)(Isolate*, Persistent<Value>, void*), class T, typename P>
+ template <void (*F)(void*)>
+ void WeakCallbackShim(Isolate* isolate, Persistent<Object>* value, void* data) {
+ F(data);
+ }
+
+ template <void (*F)(void*), class T, typename P>
void MakeWeak(Isolate* isolate, Persistent<T>& handle, P* val) {
- handle.MakeWeak(isolate, val, F);
+ handle.MakeWeak(isolate, val, WeakCallbackShim<F>);
}
template <class T>
void ClearWeak(Isolate* isolate, Persistent<T>& handle) {
@@ -62,11 +67,11 @@ namespace uni {
handle.Dispose();
}
- template <void (*F)(Isolate*, Persistent<Value>, void*)>
+ template <void (*F)(void*)>
void WeakCallbackShim(Persistent<Value> value, void* data) {
- F(NULL, value, data);
+ F(data);
}
- template <void (*F)(Isolate*, Persistent<Value>, void*), class T, typename P>
+ template <void (*F)(void*), class T, typename P>
void MakeWeak(Isolate* isolate, Persistent<T>& handle, P* val) {
handle.MakeWeak(val, WeakCallbackShim<F>);
}
@@ -143,7 +148,7 @@ class Fiber {
* i.e. After fiber completes, while yielded, or before started
*/
void MakeWeak() {
- uni::MakeWeak<WeakCallback>(isolate, handle, this);
+ uni::MakeWeak<WeakCallback>(isolate, handle, (void*)this);
}
/**
@@ -159,10 +164,9 @@ class Fiber {
* the fiber is currently suspended we'll unwind the fiber's stack by throwing exceptions in
* order to clear all references.
*/
- static void WeakCallback(Isolate* isolate, Persistent<Value> value, void* data) {
+ static void WeakCallback(void* data) {
Fiber& that = *static_cast<Fiber*>(data);
- assert(that.handle == value);
- assert(value.IsNearDeath());
+ assert(that.handle.IsNearDeath());
assert(current != &that);
// We'll unwind running fibers later... doing it from the garbage collector is bad news.
@@ -173,6 +177,7 @@ class Fiber {
return;
}
+ that.handle.Dispose();
delete &that;
}
View
2  test/child-process.js
@@ -4,7 +4,7 @@ var Fiber = require('fibers');
function main() {
var proc = require('child_process').spawn(process.execPath, [process.argv[1], 'child']);
function ondata(data) {
- require('util').print(data+ '');
+ process.stdout.write(data+ '');
}
proc.stdout.on('data', ondata);
proc.stderr.on('data', ondata);
View
2  test/exec.js
@@ -8,7 +8,7 @@ if (process.platform == 'win32') {
Fiber(function() {
require('child_process').exec('echo pass', function(err, stdout) {
if (err) console.log(err);
- require('util').print(stdout);
+ process.stdout.write(stdout);
});
}).run();
}
View
2  test/stack-overflow2.js
@@ -24,6 +24,6 @@ Fiber(function() {
function wasteStack(ii) {
ii ? wasteStack(ii - 1) : fn();
}
- wasteStack(max - 32);
+ wasteStack(max - 94);
console.log('pass');
}).run();
Please sign in to comment.
Something went wrong with that request. Please try again.