How to correctly use Context::Scope ?

99封情书 提交于 2019-12-11 00:55:48

问题


How to correctly use Context::Scope ? Do i allocate it while within a method/function scope while actually executing something or can i have a global copy of it next to the Context object ? The documentation isn't very clear on that. I want to make a global Application class and keep all the persistent stuff there not sure if i can put context scope there.


回答1:


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.).



来源:https://stackoverflow.com/questions/13842018/how-to-correctly-use-contextscope

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!