2

如何正确使用 Context::Scope ?我是在实际执行某事时在方法/函数范围内分配它,还是在 Context 对象旁边有它的全局副本?文档对此不是很清楚。我想创建一个全局应用程序类并将所有持久的东西保留在那里,不确定我是否可以将上下文范围放在那里。

4

1 回答 1

0

Context::Scope has to be allocated on the call stack outside of your call chain. What you want to do is use a Persistent<Context> to store your Context object globally, and then create a Context::Scope when you enter a JavaScript call stack. This is the case for all of V8's scope objects (HandleScope, Isolate::Scope, etc.).

于 2014-11-21T18:55:14.403 回答