Permalink
Browse files

node v0.7.9 compat

There were some libuv API changes...
  • Loading branch information...
TooTallNate committed May 29, 2012
1 parent 324465a commit 02588f775de89aecde82a43bc537dd09e71d958d
Showing with 17 additions and 2 deletions.
  1. +17 −0 src/callback_info.cc
  2. +0 −2 src/threaded_callback_invokation.cc
View
@@ -3,6 +3,7 @@
// http://www.bufferoverflow.ch/cgi-bin/dwww/usr/share/doc/libffi5/html/The-Closure-API.html
#include <node_buffer.h>
+#include <node_version.h>
#include "ffi.h"
pthread_t CallbackInfo::g_mainthread;
@@ -130,6 +131,13 @@ void CallbackInfo::Invoke(ffi_cif *cif, void *retval, void **parameters, void *u
if (pthread_equal(pthread_self(), g_mainthread)) {
DispatchToV8(info, retval, parameters);
} else {
+ // hold the event loop open while this is executing
+#if NODE_VERSION_AT_LEAST(0, 7, 9)
+ uv_ref((uv_handle_t *)&g_async);
+#else
+ uv_ref(uv_default_loop());
+#endif
+
// create a temporary storage area for our invokation parameters
ThreadedCallbackInvokation *inv = new ThreadedCallbackInvokation(info, retval, parameters);
@@ -144,6 +152,11 @@ void CallbackInfo::Invoke(ffi_cif *cif, void *retval, void **parameters, void *u
// wait for signal from calling thread
inv->WaitForExecution();
+#if NODE_VERSION_AT_LEAST(0, 7, 9)
+ uv_unref((uv_handle_t *)&g_async);
+#else
+ uv_unref(uv_default_loop());
+#endif
delete inv;
}
}
@@ -163,5 +176,9 @@ void CallbackInfo::Initialize(Handle<Object> target) {
pthread_mutex_init(&g_queue_mutex, NULL);
// allow the event loop to exit while this is running
+#if NODE_VERSION_AT_LEAST(0, 7, 9)
+ uv_unref((uv_handle_t *)&g_async);
+#else
uv_unref(uv_default_loop());
+#endif
}
@@ -7,11 +7,9 @@ ThreadedCallbackInvokation::ThreadedCallbackInvokation(callback_info *cbinfo, vo
pthread_mutex_init(&m_mutex, NULL);
pthread_cond_init(&m_cond, NULL);
- uv_ref(uv_default_loop()); // hold the event loop open while this is executing
}
ThreadedCallbackInvokation::~ThreadedCallbackInvokation() {
- uv_unref(uv_default_loop());
pthread_cond_destroy(&m_cond);
pthread_mutex_destroy(&m_mutex);
}

0 comments on commit 02588f7

Please sign in to comment.