[Pkg-javascript-commits] [node-leveldown] 342/492: late-creation of Persistent handles closes #43
Andrew Kelley
andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:14:15 UTC 2014
This is an automated email from the git hooks/post-receive script.
andrewrk-guest pushed a commit to annotated tag rocksdb-0.10.1
in repository node-leveldown.
commit 3db0d9ac60b361d1a36ae55e310c8b3f0bb8ffcf
Author: Rod Vagg <rod at vagg.org>
Date: Sat May 18 15:10:33 2013 +1000
late-creation of Persistent handles closes #43
---
src/database.cc | 18 ++++++++++--------
src/iterator.cc | 10 ++--------
src/leveldown.h | 17 ++++-------------
3 files changed, 16 insertions(+), 29 deletions(-)
diff --git a/src/database.cc b/src/database.cc
index b3cddf9..dc0522a 100644
--- a/src/database.cc
+++ b/src/database.cc
@@ -232,7 +232,7 @@ v8::Handle<v8::Value> Database::Open (const v8::Arguments& args) {
OpenWorker* worker = new OpenWorker(
database
- , callback
+ , v8::Persistent<v8::Function>::New(LD_NODE_ISOLATE_PRE callback)
, createIfMissing
, errorIfExists
, compression
@@ -253,7 +253,10 @@ v8::Handle<v8::Value> Database::Close (const v8::Arguments& args) {
LD_METHOD_SETUP_COMMON_ONEARG(close)
- CloseWorker* worker = new CloseWorker(database, callback);
+ CloseWorker* worker = new CloseWorker(
+ database
+ , v8::Persistent<v8::Function>::New(LD_NODE_ISOLATE_PRE callback)
+ );
if (database->iterators.size() > 0) {
// yikes, we still have iterators open! naughty naughty.
@@ -319,7 +322,7 @@ v8::Handle<v8::Value> Database::Put (const v8::Arguments& args) {
WriteWorker* worker = new WriteWorker(
database
- , callback
+ , v8::Persistent<v8::Function>::New(LD_NODE_ISOLATE_PRE callback)
, key
, value
, sync
@@ -350,7 +353,7 @@ v8::Handle<v8::Value> Database::Get (const v8::Arguments& args) {
ReadWorker* worker = new ReadWorker(
database
- , callback
+ , v8::Persistent<v8::Function>::New(LD_NODE_ISOLATE_PRE callback)
, key
, asBuffer
, fillCache
@@ -378,7 +381,7 @@ v8::Handle<v8::Value> Database::Delete (const v8::Arguments& args) {
DeleteWorker* worker = new DeleteWorker(
database
- , callback
+ , v8::Persistent<v8::Function>::New(LD_NODE_ISOLATE_PRE callback)
, key
, sync
, keyBuffer
@@ -464,7 +467,7 @@ v8::Handle<v8::Value> Database::Batch (const v8::Arguments& args) {
if (hasData) {
AsyncQueueWorker(new BatchWorker(
database
- , callback
+ , v8::Persistent<v8::Function>::New(LD_NODE_ISOLATE_PRE callback)
, batch
, references
, sync
@@ -472,7 +475,6 @@ v8::Handle<v8::Value> Database::Batch (const v8::Arguments& args) {
} else {
ClearReferences(references);
LD_RUN_CALLBACK(callback, NULL, 0);
- callback.Dispose(LD_NODE_ISOLATE);
}
return v8::Undefined();
@@ -509,7 +511,7 @@ v8::Handle<v8::Value> Database::ApproximateSize (const v8::Arguments& args) {
ApproximateSizeWorker* worker = new ApproximateSizeWorker(
database
- , callback
+ , v8::Persistent<v8::Function>::New(LD_NODE_ISOLATE_PRE callback)
, start
, end
, startBuffer
diff --git a/src/iterator.cc b/src/iterator.cc
index 05f9eb3..076d886 100644
--- a/src/iterator.cc
+++ b/src/iterator.cc
@@ -145,12 +145,9 @@ v8::Handle<v8::Value> Iterator::Next (const v8::Arguments& args) {
LD_RETURN_CALLBACK_OR_ERROR(callback, "cannot call next() before previous next() has completed")
}
- v8::Persistent<v8::Function> persistentCallback =
- v8::Persistent<v8::Function>::New(LD_NODE_ISOLATE_PRE callback);
-
NextWorker* worker = new NextWorker(
iterator
- , persistentCallback
+ , v8::Persistent<v8::Function>::New(LD_NODE_ISOLATE_PRE callback)
, checkEndCallback
);
iterator->nexting = true;
@@ -174,12 +171,9 @@ v8::Handle<v8::Value> Iterator::End (const v8::Arguments& args) {
LD_RETURN_CALLBACK_OR_ERROR(callback, "end() already called on iterator")
}
- v8::Persistent<v8::Function> persistentCallback =
- v8::Persistent<v8::Function>::New(LD_NODE_ISOLATE_PRE callback);
-
EndWorker* worker = new EndWorker(
iterator
- , persistentCallback
+ , v8::Persistent<v8::Function>::New(LD_NODE_ISOLATE_PRE callback)
);
iterator->ended = true;
diff --git a/src/leveldown.h b/src/leveldown.h
index af55581..6578f80 100644
--- a/src/leveldown.h
+++ b/src/leveldown.h
@@ -152,25 +152,16 @@ static inline void DisposeStringOrBufferFromSlice(v8::Persistent<v8::Value> ptr
leveldown::Database* database = \
node::ObjectWrap::Unwrap<leveldown::Database>(args.This()); \
v8::Local<v8::Object> optionsObj; \
- v8::Persistent<v8::Function> callback; \
+ v8::Local<v8::Function> callback; \
if (optionPos == -1 && args[callbackPos]->IsFunction()) { \
- callback = v8::Persistent<v8::Function>::New( \
- LD_NODE_ISOLATE_PRE \
- v8::Local<v8::Function>::Cast(args[callbackPos]) \
- ); \
+ callback = v8::Local<v8::Function>::Cast(args[callbackPos]); \
} else if (optionPos != -1 && args[callbackPos - 1]->IsFunction()) { \
- callback = v8::Persistent<v8::Function>::New( \
- LD_NODE_ISOLATE_PRE \
- v8::Local<v8::Function>::Cast(args[callbackPos - 1]) \
- ); \
+ callback = v8::Local<v8::Function>::Cast(args[callbackPos - 1]); \
} else if (optionPos != -1 \
&& args[optionPos]->IsObject() \
&& args[callbackPos]->IsFunction()) { \
optionsObj = v8::Local<v8::Object>::Cast(args[optionPos]); \
- callback = v8::Persistent<v8::Function>::New( \
- LD_NODE_ISOLATE_PRE \
- v8::Local<v8::Function>::Cast(args[callbackPos]) \
- ); \
+ callback = v8::Local<v8::Function>::Cast(args[callbackPos]); \
} else { \
LD_THROW_RETURN(name() requires a callback argument) \
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-leveldown.git
More information about the Pkg-javascript-commits
mailing list