You need to grab a Persistent handle, not a Local one. Local handles are
only valid in the current scope, once the current HandleScope unwinds the
handle is invalid. In the case of threads, this is what you are running
into.

Your problem can be fixed as easily as doing:
Persistent<Value> handle = Persistent<Value>::New(local_handle);

Where local_handle is whatever you have now. You *must* be sure to call
handle.Dispose() on this persistent handle when you're done with it, or it
will never garbage collect. Additionally you still must use the Locker API
or you will run into access violations, even if your thread is read-only.

If you want to actually *copy* the object, that is a little bit more tricky
:)


On Thu, Apr 11, 2013 at 1:28 AM, Jerry Yin <yinpen...@gmail.com> wrote:

> Thanks for your reply. I used locks.
>
> My question is how to share a v8::Local<v8::Value> between thread?
>
>
> On Thursday, April 11, 2013 4:24:45 PM UTC+8, Floby wrote:
>>
>> Anything you touch from multiple thread must get a lock
>> http://msdn.microsoft.com/en-**us/magazine/cc163744.aspx#S3<http://msdn.microsoft.com/en-us/magazine/cc163744.aspx#S3>
>>
>>>
>>>> H.-
>>>>
>>>> On 4/10/13 11:45 PM, Jerry Yin wrote:
>>>> > Hi,
>>>> >
>>>> > I worked on an addon and tried to put some Value in a global
>>>> > std::vector, and try to use it later in another thread.
>>>> >
>>>> > While when I try to access the Value, it will throw some error
>>>> related thin> to isolation.
>>>> >
>>>> > How to make the value accessible in another thread?
>>>> >
>>>> > Thanks.
>>>> > Jerry
>>>> > --
>>>> >
>>>>
>>>>  --
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nodejs+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to