summaryrefslogtreecommitdiff
path: root/src/mongo/scripting/v8_db.cpp
diff options
context:
space:
mode:
authorBen Becker <ben.becker@10gen.com>2013-02-12 11:13:35 -0800
committerBen Becker <ben.becker@10gen.com>2013-02-12 12:33:12 -0800
commit75b0536f0032627241fbad47baba64322834e523 (patch)
tree7433a3cc9abea8b56cc2e06ad3644bec406e309a /src/mongo/scripting/v8_db.cpp
parent65ed5f4d576e380ae9e59ca7ae9d6b06b9d9766c (diff)
downloadmongo-75b0536f0032627241fbad47baba64322834e523.tar.gz
SERVER-8170: cleanup and unify GC callbacks
Diffstat (limited to 'src/mongo/scripting/v8_db.cpp')
-rw-r--r--src/mongo/scripting/v8_db.cpp19
1 files changed, 4 insertions, 15 deletions
diff --git a/src/mongo/scripting/v8_db.cpp b/src/mongo/scripting/v8_db.cpp
index 6e7866515af..d0733c2d7ca 100644
--- a/src/mongo/scripting/v8_db.cpp
+++ b/src/mongo/scripting/v8_db.cpp
@@ -103,11 +103,6 @@ namespace mongo {
return mongo;
}
- void destroyConnection(v8::Persistent<v8::Value> self, void* parameter) {
- delete static_cast<DBClientBase*>(parameter);
- self.Dispose();
- self.Clear();
- }
v8::Handle<v8::Value> mongoConsExternal(V8Scope* scope, const v8::Arguments& args) {
char host[255];
@@ -132,7 +127,7 @@ namespace mongo {
}
v8::Persistent<v8::Object> self = v8::Persistent<v8::Object>::New(args.Holder());
- self.MakeWeak(conn, destroyConnection);
+ self.MakeWeak(conn, deleteOnCollect<DBClientWithCommands>);
ScriptEngine::runConnectCallback(*conn);
@@ -148,7 +143,7 @@ namespace mongo {
DBClientBase* conn = createDirectClient();
v8::Persistent<v8::Object> self = v8::Persistent<v8::Object>::New(args.This());
- self.MakeWeak(conn, destroyConnection);
+ self.MakeWeak(conn, deleteOnCollect<DBClientBase>);
args.This()->SetInternalField(0, v8::External::New(conn));
args.This()->ForceSet(scope->v8StringData("slaveOk"), v8::Boolean::New(false));
@@ -164,12 +159,6 @@ namespace mongo {
return conn;
}
- void destroyCursor(v8::Persistent<v8::Value> self, void* parameter) {
- delete static_cast<mongo::DBClientCursor*>(parameter);
- self.Dispose();
- self.Clear();
- }
-
/**
* JavaScript binding for Mongo.prototype.find(namespace, query, fields, limit, skip)
*/
@@ -204,8 +193,8 @@ namespace mongo {
}
v8::Persistent<v8::Object> c = v8::Persistent<v8::Object>::New(cons->NewInstance());
- c.MakeWeak(cursor.get(), destroyCursor);
- c->SetInternalField(0, v8::External::New(cursor.release()));
+ c->SetInternalField(0, v8::External::New(cursor.get()));
+ c.MakeWeak(cursor.release(), deleteOnCollect<DBClientCursor>);
return c;
}