当我尝试使持久句柄变弱时,为什么不调用 WeakReferenceCallback?请参阅以下示例:
void myWeakReferenceCallback(v8::Persistent<v8::Value> theValue, void *theParameter)
{
fprintf(stdout, "myWeakReferenceCallback");
}
void testWeakReferenceCallback()
{
v8::Persistent<v8::Value> persistent_value;
{
v8::Persistent<v8::Context> context = v8::Context::New();
v8::Context::Scope context_scope(context);
v8::HandleScope handle_scope;
v8::Local<v8::Value> local_value = v8::NumberObject::New(5.0);
persistent_value = v8::Persistent<v8::Value>::New(local_value);
persistent_value.MakeWeak(NULL, myWeakReferenceCallback);
context.Dispose();
}
persistent_value.Dispose();
}