[Pkg-javascript-commits] [node-leveldown] 446/492: save parent object as persistent during async work
Andrew Kelley
andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:14:30 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 428e120ece5c07e6aa6f2e2870124af9c03a8260
Author: Rod Vagg <rod at vagg.org>
Date: Fri Nov 15 21:18:28 2013 +1100
save parent object as persistent during async work
---
src/batch.cc | 3 +++
src/database.cc | 27 ++++++++++++++++++++++++---
src/iterator.cc | 6 ++++++
3 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/src/batch.cc b/src/batch.cc
index 7a9236a..d0205b7 100644
--- a/src/batch.cc
+++ b/src/batch.cc
@@ -163,6 +163,9 @@ NAN_METHOD(Batch::Write) {
NanCallback *callback =
new NanCallback(v8::Local<v8::Function>::Cast(args[0]));
BatchWriteWorker* worker = new BatchWriteWorker(batch, callback);
+ // persist to prevent accidental GC
+ v8::Local<v8::Object> _this = args.This();
+ worker->SavePersistent("batch", _this);
NanAsyncQueueWorker(worker);
} else {
LD_RUN_CALLBACK(v8::Local<v8::Function>::Cast(args[0]), 0, NULL);
diff --git a/src/database.cc b/src/database.cc
index 9d64b2b..5fbac65 100644
--- a/src/database.cc
+++ b/src/database.cc
@@ -231,7 +231,9 @@ NAN_METHOD(Database::Open) {
, maxOpenFiles
, blockRestartInterval
);
-
+ // persist to prevent accidental GC
+ v8::Local<v8::Object> _this = args.This();
+ worker->SavePersistent("database", _this);
NanAsyncQueueWorker(worker);
NanReturnUndefined();
@@ -246,6 +248,9 @@ NAN_METHOD(Database::Close) {
database
, new NanCallback(callback)
);
+ // persist to prevent accidental GC
+ v8::Local<v8::Object> _this = args.This();
+ worker->SavePersistent("database", _this);
if (!database->iterators.empty()) {
// yikes, we still have iterators open! naughty naughty.
@@ -319,6 +324,9 @@ NAN_METHOD(Database::Put) {
, keyHandle
, valueHandle
);
+ // persist to prevent accidental GC
+ v8::Local<v8::Object> _this = args.This();
+ worker->SavePersistent("database", _this);
NanAsyncQueueWorker(worker);
NanReturnUndefined();
@@ -345,6 +353,9 @@ NAN_METHOD(Database::Get) {
, fillCache
, keyHandle
);
+ // persist to prevent accidental GC
+ v8::Local<v8::Object> _this = args.This();
+ worker->SavePersistent("database", _this);
NanAsyncQueueWorker(worker);
NanReturnUndefined();
@@ -369,6 +380,9 @@ NAN_METHOD(Database::Delete) {
, sync
, keyHandle
);
+ // persist to prevent accidental GC
+ v8::Local<v8::Object> _this = args.This();
+ worker->SavePersistent("database", _this);
NanAsyncQueueWorker(worker);
NanReturnUndefined();
@@ -431,12 +445,16 @@ NAN_METHOD(Database::Batch) {
// don't allow an empty batch through
if (hasData) {
- NanAsyncQueueWorker(new BatchWorker(
+ BatchWorker* worker = new BatchWorker(
database
, new NanCallback(callback)
, batch
, sync
- ));
+ );
+ // persist to prevent accidental GC
+ v8::Local<v8::Object> _this = args.This();
+ worker->SavePersistent("database", _this);
+ NanAsyncQueueWorker(worker);
} else {
LD_RUN_CALLBACK(callback, 0, NULL);
}
@@ -476,6 +494,9 @@ NAN_METHOD(Database::ApproximateSize) {
, startHandle
, endHandle
);
+ // persist to prevent accidental GC
+ v8::Local<v8::Object> _this = args.This();
+ worker->SavePersistent("database", _this);
NanAsyncQueueWorker(worker);
NanReturnUndefined();
diff --git a/src/iterator.cc b/src/iterator.cc
index 7797791..e6fde6d 100644
--- a/src/iterator.cc
+++ b/src/iterator.cc
@@ -199,6 +199,9 @@ NAN_METHOD(Iterator::Next) {
, new NanCallback(callback)
, checkEndCallback
);
+ // persist to prevent accidental GC
+ v8::Local<v8::Object> _this = args.This();
+ worker->SavePersistent("iterator", _this);
iterator->nexting = true;
NanAsyncQueueWorker(worker);
@@ -223,6 +226,9 @@ NAN_METHOD(Iterator::End) {
iterator
, new NanCallback(callback)
);
+ // persist to prevent accidental GC
+ v8::Local<v8::Object> _this = args.This();
+ worker->SavePersistent("iterator", _this);
iterator->ended = true;
if (iterator->nexting) {
--
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