I managed to get the thing working using libev.  Thanks for the pointer,
though.

--
Chandra Sekar.S


On Tue, Jul 6, 2010 at 3:02 PM, Chandru <[email protected]> wrote:

> Thanks for the help.  Can you point me to some sample code online which
> does something like this?
>
> --
> Chandra Sekar.S
>
>
>
> On Tue, Jul 6, 2010 at 2:48 PM, Matthias Ernst <[email protected]>wrote:
>
>> On Tue, Jul 6, 2010 at 10:06 AM, Chandru <[email protected]> wrote:
>> > I have a C++ which when invoked from JS will start a new thread and do
>> > some processing.  When completed, this thread would invoke a Function
>> > which was passed as argument to the original function.
>> >
>> > The function used for the new thread (pthread) is (simplified to just
>> > sum values with delay and display it),
>> >
>> >        static void *execute(void *data) {
>> >            HandleScope scope;
>> >            ComputeData *cData = (ComputeData *) data;
>> >            Local<Value> val = Number::New(cData->a + cData->b);
>> >            sleep(2);
>> >            cout << val->NumberValue() << endl;
>> >            delete cData;
>> >            return NULL;
>> >        }
>> >
>> > This piece of code prints nan instead of the actual sum.  data is a
>> > dynamically allocated pointer to a struct with the values to add.
>> >
>> > What's wrong here?  I've no prior V8 experience.
>>
>> V8 is not multithreaded - in the sense that you cannot access V8
>> concurrently without synchronizing through the v8::Locker. You are
>> probably best advised to stick to one thread that interacts with V8,
>> extract the data you want to compute there, spawn your worker, and
>> once it's done communicate the result back to V8.
>>
>> Matthias
>>
>> --
>> v8-users mailing list
>> [email protected]
>> http://groups.google.com/group/v8-users
>
>
>

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

Reply via email to