Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixes to support node >= v0.7.9

Use the new uv_ref()/uv_unref() API for node >= v0.7.9, and remove a couple
unnecessary instances of uv_ref()/uv_unref() where only uv_queue_work() was
being used.
  • Loading branch information...
commit 211f277a641caa216173aed25051dbf070c9a4ba 1 parent d4fe338
@TooTallNate TooTallNate authored
Showing with 9 additions and 4 deletions.
  1. +9 −0 src/async.h
  2. +0 −2  src/database.h
  3. +0 −2  src/statement.h
View
9 src/async.h
@@ -2,6 +2,7 @@
#define NODE_SQLITE3_SRC_ASYNC_H
#include "threading.h"
+#include <node_version.h>
#if defined(NODE_SQLITE3_BOOST_THREADING)
#include <boost/thread/mutex.hpp>
@@ -35,7 +36,11 @@ template <class Item, class Parent> class Async {
rows.swap(async->data);
NODE_SQLITE3_MUTEX_UNLOCK(&async->mutex)
for (unsigned int i = 0, size = rows.size(); i < size; i++) {
+#if NODE_VERSION_AT_LEAST(0, 7, 9)
+ uv_unref((uv_handle_t *)&async->watcher);
+#else
uv_unref(uv_default_loop());
+#endif
async->callback(async->parent, rows[i]);
}
}
@@ -58,7 +63,11 @@ template <class Item, class Parent> class Async {
void add(Item* item) {
// Make sure node runs long enough to deliver the messages.
+#if NODE_VERSION_AT_LEAST(0, 7, 9)
+ uv_ref((uv_handle_t *)&watcher);
+#else
uv_ref(uv_default_loop());
+#endif
NODE_SQLITE3_MUTEX_LOCK(&mutex);
data.push_back(item);
NODE_SQLITE3_MUTEX_UNLOCK(&mutex)
View
2  src/database.h
@@ -38,13 +38,11 @@ class Database : public ObjectWrap {
Baton(Database* db_, Handle<Function> cb_) :
db(db_), status(SQLITE_OK) {
db->Ref();
- uv_ref(uv_default_loop());
request.data = this;
callback = Persistent<Function>::New(cb_);
}
virtual ~Baton() {
db->Unref();
- uv_unref(uv_default_loop());
callback.Dispose();
}
};
View
2  src/statement.h
@@ -86,7 +86,6 @@ class Statement : public ObjectWrap {
Baton(Statement* stmt_, Handle<Function> cb_) : stmt(stmt_) {
stmt->Ref();
- uv_ref(uv_default_loop());
request.data = this;
callback = Persistent<Function>::New(cb_);
}
@@ -96,7 +95,6 @@ class Statement : public ObjectWrap {
DELETE_FIELD(field);
}
stmt->Unref();
- uv_unref(uv_default_loop());
callback.Dispose();
}
};
Please sign in to comment.
Something went wrong with that request. Please try again.