Hi Soren Thanks for review.
I redid the program so that it supports both main cycle in C++ part and main cycle in JS part. This way it still illustrates the case of C++ being busy while quick cycle of V8 is required to process debugger messages, but now it does it in 2 different scenarios: 1. Processor is busy with C++ and V8 is not currently running (main cycle in C++) 2. JS is running, but has called slow C++ function, making processor busy in C++ again. In this case I plan to call "void(0)" in V8 in other thread, while C++ is doing whatever it does. I don't know though whether V8 is OK with being blocked in one thread and then being called in other thread. http://codereview.chromium.org/491006/diff/3001/3002 File samples/lineprocessor.cc (right): http://codereview.chromium.org/491006/diff/3001/3002#newcode43 samples/lineprocessor.cc:43: * When program starts, script gets compiled and run. To this point should On 2009/12/11 11:20:01, Søren Gjesse wrote: > I don't see why this sample should require any specific function to be declared. > How about just run the scripts. You can then define callback functions for feof > and fgets (call them something else though) and then have the suggested > JavaScript code have a top-level loop doing the RunCycle work. It was important for me to demonstrate a program, that is running V8 only part-time and gets occupied most of the time by something else. This way it needs to give a callback to DebugAgent. On the other hand you are describing another interesting case: when V8 executes a long script which passes a control back to C++. C++ call may take long, so it is important to be able to quickly give control back to V8 to process debugger messages, while C++ call still goes. So I redid a program, added CycleType enum and supported 2 modes: main cycle in C++ and main cycle in JS. http://codereview.chromium.org/491006/diff/3001/3002#newcode63 samples/lineprocessor.cc:63: * allows remote debugger to attach and debug custom JavaScript code. On 2009/12/11 11:20:01, Søren Gjesse wrote: > Maybe delete "custom" Done. http://codereview.chromium.org/491006/diff/3001/3002#newcode66 samples/lineprocessor.cc:66: * 1. Wait for remote debugger to attach On 2009/12/11 11:20:01, Søren Gjesse wrote: > With the forced break in wait for connection the "debugger" statement is no > longer needed. Done. http://codereview.chromium.org/491006/diff/3001/3002#newcode115 samples/lineprocessor.cc:115: // TODO(peter.rybin): implement this. On 2009/12/11 11:20:01, Søren Gjesse wrote: > Please open a bug on this and change to TODO(bugnumber). Done. http://codereview.chromium.org/491006/diff/3001/3002#newcode119 samples/lineprocessor.cc:119: // TODO(peter.rybin): implement this. On 2009/12/11 11:20:01, Søren Gjesse wrote: > TODO(bugnumber) here as well. It is already implemented http://codereview.chromium.org/491006/diff/3001/3002#newcode170 samples/lineprocessor.cc:170: // Run script. As a result the script should declare "ProcessLine" function On 2009/12/11 11:20:01, Søren Gjesse wrote: > I don't think this sample needs to require specific code in the JavaScript files > processed. I came to this because: 1. I wanted main cycle to be in C++ side, so I needed to call some callback in JavaScript. 2. I wanted to split script into 2 parts: initialization part (the script itself does initialization) and callback for each line (ProcessLine function becomes this callback). http://codereview.chromium.org/491006/diff/3001/3002#newcode200 samples/lineprocessor.cc:200: bool RunCycle(v8::Handle<v8::Function> process_fun, bool report_exceptions) { On 2009/12/11 11:20:01, Søren Gjesse wrote: > Remove empty line? Done. http://codereview.chromium.org/491006/diff/3001/3002#newcode221 samples/lineprocessor.cc:221: v8::Handle<v8::String> input_line = v8::String::New(buffer); On 2009/12/11 11:20:01, Søren Gjesse wrote: > Remove {}'s? Oops. Done http://codereview.chromium.org/491006 -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
