Ignore:
Timestamp:
03/22/13 17:31:33 (12 years ago)
Author:
tbretz
Message:
Replaced the pre-compiled v8.sleep() by an ulock and a usleep, which should have the same effect; added the count function to the String object
File:
1 edited

Legend:

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

    r15129 r15138  
    148148    TryCatch exception;
    149149
    150     const Handle<Script> sleep = Script::Compile(String::New("v8.sleep();"), String::New("internal"));
    151     if (sleep.IsEmpty())
    152         return Undefined();
     150    //const Handle<Script> sleep = Script::Compile(String::New("v8.sleep();"), String::New("internal"));
     151    //if (sleep.IsEmpty())
     152    //    return Undefined();
    153153
    154154    Handle<Function> func = Handle<Function>::Cast(args[1]);
     
    171171        // JavaScript ever now and then. This also allows us to catch
    172172        // exceptions, either from the preemption or ConvertEvent
    173         sleep->Run();
     173        //sleep->Run();
     174
     175        // Theoretically, the CPU usage can be reduced by maybe a factor
     176        // of four using a larger value, but this also means that the
     177        // JavaScript is locked for a longer time.
     178        const Unlocker unlock;
     179        usleep(1000);
    174180    }
    175181
     
    12141220    HandleScope handle_scope;
    12151221
    1216     const Handle<Script> sleep = Script::Compile(String::New("v8.sleep();"), String::New("internal"));
    1217     if (sleep.IsEmpty())
    1218         return Undefined();
     1222    //const Handle<Script> sleep = Script::Compile(String::New("v8.sleep();"), String::New("internal"));
     1223    //if (sleep.IsEmpty())
     1224    //    return Undefined();
    12191225
    12201226    const Handle<String> data   = String::New("data");
     
    12731279        // JavaScript ever now and then. This also allows us to catch
    12741280        // exceptions, either from the preemption or ConvertEvent
    1275         sleep->Run();
     1281        //sleep->Run();
     1282
     1283        // Theoretically, the CPU usage can be reduced by maybe a factor
     1284        // of four using a larger value, but this also means that the
     1285        // JavaScript is locked for a longer time.
     1286        const Unlocker unlock;
     1287        usleep(1000);
    12761288    }
    12771289
     
    22152227        "{"
    22162228            "return String.form(this, Array.prototype.slice.call(arguments));"
     2229        "}"
     2230        "\n"
     2231        "String.prototype.count = function(c,i)"
     2232        "{"
     2233            "return (this.match(new RegExp(c,i?'gi':'g'))||[]).length;"
    22172234        "}"/*
    22182235        "\n"
Note: See TracChangeset for help on using the changeset viewer.