Ok.  I made an implementation called "ScriptManager" that uses the
preemption + terminate execution.

http://pastebin.com/M801zbDB

It uses basic stuff inside of V8's platform specific code such as
threads, sleeping and current time.  I have done some testing, but I
would like some feedback to see if this method looks good.  I'm not
very good at concurrent programming so this does not use any
synchronization methods... If there is an obvious place to add a mutex
or semaphore to avoid a deadlock or get rid of the sleep call or while
loop, please let me know. It seems to me that the terminate execution
call does not have side effects if the javascript is not running when
it gets called.  It just does nothing.  I think that makes this a bit
easier.

Once we make this better, we should attempt to query the V8 developers
and get this added in the samples directory of the source.



On Aug 13, 5:10 pm, Mikhail Naganov <[email protected]> wrote:
> I think it's OK. This is a part of debugger API, because debugger
> needs to be able to intervent into script execution at arbitrary
> moments. And you don't need a debug version of V8, you just need to
> make sure that you compile with ENABLE_DEBUGGER_SUPPORT defined.
> Debugging JS inside V8 isn't the same as debugging V8 itself.
>
> But using preemption and lockers is a good approach as well.
>
>
>
>
>
>
>
> On Fri, Aug 12, 2011 at 19:07, mcot <[email protected]> wrote:
> > Also... it seems bad to use the debugger api's for this task.  For
> > one, wouldn't you have to compile v8 in debug mode and link against
> > v8_g?
>
> > --
> > v8-users mailing list
> > [email protected]
> >http://groups.google.com/group/v8-users

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to