Use Global<Function> to save js closure

35 views
Skip to first unread message

Ivan Y

unread,
Mar 24, 2017, 6:25:21 AM3/24/17
to v8-users
Hi, there 

    When I use Global<Function> to save a js closure( a function uses external function or variable) and call it next time, whether those external function or variable need to be compiled again. In other word, can Global<Function> save the function and external functions or variables it refers without compiling again.

test.js

for example,  read the script, compile, run and save the return funtion object to Global<Function>:


Global<Function> process_;

Handle<v8::Script> compiled_script = v8::Script::Compile(script); // script is a string read from test.js
Local<Value> result = compiled_script->Run();                        // result = function object "main"
Local<Function> process_fun = Local<Function>::Cast(result);
process_.Reset(GetIsolate(), process_fun); 


 



 
Reply all
Reply to author
Forward
0 new messages