Google Javascript v8 - multithreading

Posted by willem on Stack Overflow See other posts from Stack Overflow or by willem
Published on 2010-05-10T12:31:54Z Indexed on 2010/05/17 8:10 UTC
Read the original article Hit count: 391

Filed under:
|
|
|

Hi guys

Suppose I have the following piece of code

bool run (void)
{
    HandleScope hande_scope;
    Handle<String> source;
    Local<Script> script;
    Persistent<Context> context;

    context = Context::New();
    Context::Scope context_scope(context);

    script = Script::Compile("var a = 1; var b = 2;");
    Local<Value> result = script->Run();

    if (result.IsEmpty())
        return false;
    else
        return true;

}

Is it true that one cannot execute this code using multiple threads? It seems like HandleScope is not designed to be used in multithreaded applications. I can use the v8::Locker and v8::Unlocker methodes but that would always give me execution traces as this:

t1: a = 1
t1: b = 2

t2: a = 1
t2: b = 2

I hope someone can give me a hint on getting this code multithreaded so that a possible execution trace could like this:

t1: a = 1
t2: a = 1

t1: b = 2
t2: b = 2

Thanks already in advance!

Willem

-- EDIT -- So I guess that this question has no answer :)

© Stack Overflow or respective owner

Related posts about google

Related posts about JavaScript