From 963c93f87d3fd3ff59700af9b5a7124760cd894c Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Sun, 5 Jul 2015 19:33:05 -0500 Subject: [PATCH] add documentation for `clearReferences` method --- ext/v8/isolate.cc | 2 +- ext/v8/isolate.h | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/ext/v8/isolate.cc b/ext/v8/isolate.cc index 98ca657..5f5afa2 100644 --- a/ext/v8/isolate.cc +++ b/ext/v8/isolate.cc @@ -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; } diff --git a/ext/v8/isolate.h b/ext/v8/isolate.h index 252408b..7a2c045 100644 --- a/ext/v8/isolate.h +++ b/ext/v8/isolate.h @@ -33,15 +33,6 @@ namespace rr { inline Isolate(v8::Isolate* isolate) : Pointer(isolate) {} inline Isolate(VALUE value) : Pointer(value) {} - static void clearDeadReferences(v8::Isolate* i, v8::GCType type, v8::GCCallbackFlags flags) { - Isolate isolate(i); - v8::Persistent* 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*)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* cell; + while (isolate.data()->queue.try_dequeue(cell)) { + cell->Reset(); + delete cell; + } + } + + static VALUE Dispose(VALUE self); /**