1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00

add documentation for clearReferences method

This commit is contained in:
Charles Lowell 2015-07-05 19:33:05 -05:00
parent 6cda380dec
commit 963c93f87d
2 changed files with 16 additions and 10 deletions

View file

@ -21,7 +21,7 @@ namespace rr {
create_params.array_buffer_allocator = &data->array_buffer_allocator;
Isolate isolate(v8::Isolate::New(create_params));
isolate->SetData(0, new IsolateData());
isolate->AddGCPrologueCallback(&clearDeadReferences);
isolate->AddGCPrologueCallback(&clearReferences);
return isolate;
}

View file

@ -33,15 +33,6 @@ namespace rr {
inline Isolate(v8::Isolate* isolate) : Pointer<v8::Isolate>(isolate) {}
inline Isolate(VALUE value) : Pointer<v8::Isolate>(value) {}
static void clearDeadReferences(v8::Isolate* i, v8::GCType type, v8::GCCallbackFlags flags) {
Isolate isolate(i);
v8::Persistent<void>* cell;
while (isolate.data()->queue.try_dequeue(cell)) {
cell->Reset();
delete cell;
}
}
/**
* Converts the v8::Isolate into a Ruby Object, while setting up
* its book keeping data. E.g.
@ -69,6 +60,21 @@ namespace rr {
data()->queue.enqueue((v8::Persistent<void>*)cell);
}
/**
* An instance of v8::GCPrologueCallback, this will run in the v8
* GC thread, and clear out all the references that have been
* released from Ruby.
*/
static void clearReferences(v8::Isolate* i, v8::GCType type, v8::GCCallbackFlags flags) {
Isolate isolate(i);
v8::Persistent<void>* cell;
while (isolate.data()->queue.try_dequeue(cell)) {
cell->Reset();
delete cell;
}
}
static VALUE Dispose(VALUE self);
/**