我可以某种方式持久v8::Isolate::Scope
,v8::HandleScope
和v8::Context::Scope
吗?
我知道我可以创建持久化的上下文 - v8::Persistent<v8::Context, v8::CopyablePersistentTraits<v8::Context>> pContext(isolate, v8::Context::New(isolate, nullptr, global));
和持久性函数,但是我可以实际保留上面列出的所有范围吗?
这样我就可以消除这样的范围堆栈变量:
v8::Isolate::Scope isolate_scope(isolate); // can I persist isolate_scope ?
v8::HandleScope scope(isolate); // can I persist handlescope ?
v8::Local<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
global->Set(v8::String::NewFromUtf8(isolate, "print"), v8::FunctionTemplate::New(isolate, Print));
global->Set(v8::String::NewFromUtf8(isolate, "require"), v8::FunctionTemplate::New(isolate, Require));
v8::Persistent<v8::Context, v8::CopyablePersistentTraits<v8::Context>> pContext(isolate, v8::Context::New(isolate, nullptr, global));
v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolate, pContext);
v8::Context::Scope context_scope(context); // can I persist this ?
非常感谢。