Ignore:
Timestamp:
11/10/12 13:19:58 (12 years ago)
Author:
tbretz
Message:
Allow 0 timeout, added a check for Locking in Terminate; added some documentatation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/InterpreterV8.cc

    r14600 r14601  
    3838// ------------
    3939// Each thread running V8 code needs to be signalled individually for
    40 // termination.
     40// termination. Therefor a list of V8 thread ids is created.
    4141//
     42// If temrination has already be signalled, no thread should start running
     43// anymore (thy could, e.g., wait for their locking). So after locking
     44// it has to be checked if the thread was terminated already. Note
     45// that all calls to Terminate() must be locked to ensure that fThreadId
     46// is correct when it is checked.
     47//
     48// Empty handles:
     49// --------------
     50// If exceution is terminated, V8 calls might return with empty handles,
     51// e.g. Date::New(). Therefore, the returned handles of these calls have to
     52// be checked in all placed to avoid that V8 will core dump.
     53//
    4254
    4355// ==========================================================================
     
    4759void InterpreterV8::Terminate()
    4860{
    49     /*
     61    if (!Locker::IsLocked())
     62        JsException("***** InterprterV8::Terminate call not locked *****");
     63
    5064    for (auto it=fThreadIds.begin(); it!=fThreadIds.end(); it++)
    5165        V8::TerminateExecution(*it);
    5266    fThreadIds.clear();
    53     */
    54     if (fThreadId<0)
    55         return;
    56 
    57     V8::TerminateExecution(fThreadId);
    58     fThreadId = -1;
     67
     68    if (fThreadId>=0)
     69    {
     70        V8::TerminateExecution(fThreadId);
     71        fThreadId = -1;
     72    }
    5973}
    6074
     
    118132
    119133    const Handle<Script> sleep = Script::Compile(String::New(("dim.sleep("+to_string(ms)+");").c_str()));
    120     if (!sleep.IsEmpty() && !sleep->Run().IsEmpty())
     134    if (ms==0 || (!sleep.IsEmpty() && !sleep->Run().IsEmpty()))
    121135    {
    122136        Handle<Value> args[] = {  };
Note: See TracChangeset for help on using the changeset viewer.