If you scripts are idle most of the time - that means that are simply
processing request, right?
Then you should do something like this. Just manage requests...

// compile script and save pointer to func

        Local<Script> code = Script::Compile(String::New(script_code.data
()));
        if (!try_catch.HasCaught())
              Local<Value> result = code->Run();

        if (!try_catch.HasCaught())
       {
                Local<Value> func = client_context.v8_context->Global()->Get
(String::New(func_name));
                if (func->IsFunction())
                        Persistent<Function> func_ptr = 
Persistent<Function>::New
(Handle<Function>::Cast(func));

       }


And later than you have a request to processed you enter context and
call the function and pass a request data.

...
  const int argc = 1;
  Local<Value> argv[argc] = { String::New("some bla bla bla") };
  Local<Value> result = func_ptr->Call(client_context.v8_context-
>Global(), argc, argv);
...



On 12 сен, 10:21, "Kei Yuen (Kenji)" <[email protected]> wrote:
> Hi, I have a similar situation too.
> In my case, my server needs to host a large number of long running scripts,
> but many of them are idle most of the time.
>
> If creating 1000 threads for 1000 scripts isn't a problem, that is to create
> 1 thread, 1 V8 context for 1 script.
> How well can V8 perform in this case?
> Since V8 has a lot of static global data, would that be a problem for V8?
>
> Thanks,
>
> Kenji
>

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

Reply via email to