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:
parent
6cda380dec
commit
963c93f87d
2 changed files with 16 additions and 10 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue