Funny, I just posted a very similar question. See
http://groups.google.com/group/v8-users/t/653df06a4e0748f6

On 9 Apr, 21:10, Sébastien <[email protected]> wrote:
>
> Here is how I create the thread (posix_PTHREAD is an object with an
> internal field to store the thread value)
>
> static Handle<v8::Value> js_pthread_create (Arguments& args) {
>         HandleScope handlescope;
>         Handle<Function> callback = Handle<Function>::Cast(args[(0)])
[snip]

This is equivalent to my corresponding code, I think.

> void* posix_pthread_create_callback(void* context) {
>         Locker locker;
>         HandleScope HandleScope;
>
>         printf("Starting new thread...\n");
>
>         Object*    context_obj = reinterpret_cast<Object*>(context);
>         Handle<Function> callback_v = Handle<Function>::Cast(context_obj->Get 
> (JS_str("callback")));
>
>         callback_v->Call(Context::GetCurrent()->Global(), 0, NULL);

I pass the Function itself as receiver:
    callback_v->Call(callback_v, 0, NULL);
- but that's copied blindly from some other post, not sure why it
works.
And, as mentioned, I get random crashes when something has been moved
(possibly - there is always a Handle<Object> with 0x0baddead value
anyway)

    k

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

Reply via email to