I'm trying to embed V8 into an existing code that already has a mainloop.

As I understand it, script->Run() is executed before the script finishes 
executing its "main body" (global scope).

The main problem is that in this case my mainloop will hang until the 
script is executed(My application is single-threaded). Executing scripts in 
a separate thread also does not look like a good solution, because for each 
API call of my application from the script, I will have to synchronize the 
mainloop and the script thread, which in the end can greatly affect the 
performance and quality of the code.

Also, it would be nice if it was possible to forcibly suspend the execution 
of JS from the script itself (for example, with the yield function)

Here are the "crutch" solution ideas that are currently available, but they 
feel terrible:

   1. Creating Fibers for each script, and switching them with the main 
   thread. But in this case, it seems to me that I will break a lot of 
   mechanisms inside the engine.
   2. Using v8::TryCatch and TerminateExecution.
   3. Using the v8 debugging API to suspend the script by the "debugger"


Also, I tried to write my own implementation v8::Platform, but v8 still 
executes javascript code synchornously(blocking current thread)

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/4bb8905a-5570-476c-99ed-1e089d9e341bn%40googlegroups.com.

Reply via email to