Commit 211f277a by Nathan Rajlich

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.
parent d4fe3387
......@@ -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 @@ public:
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 @@ public:
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)
......
......@@ -38,13 +38,11 @@ public:
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();
}
};
......
......@@ -86,7 +86,6 @@ public:
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 @@ public:
DELETE_FIELD(field);
}
stmt->Unref();
uv_unref(uv_default_loop());
callback.Dispose();
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment