But if you centralize the storage and information associated with an
indirection, then all copies, weak or otherwise should point to the same
object.  If during a weak callback disposes the handle, and others are
referring to it such that it isn't the last reference, the memory
associated with the handle shouldn't be disposed, but the handle data
should be.  Then, the other handles when calling IsEmpty should return
true.  The centralized data used for the Persistent is reference counted
and only when the reference count becomes zero should the actual
centralized storage memory be disposed.  Make sense?


On Thu, Aug 22, 2013 at 11:37 PM, Dan Carney <[email protected]> wrote:

> On Friday, August 23, 2013 12:12:31 AM UTC+2, Jim Acquavella wrote:
>
>> Why can't the Persistent use a RIAA pattern that's reference counted?
>>  Ideally, I'd like to create a persistent, copy it to another persistent
>> (which would increment the reference), then the last one to go out of scope
>> should be disposed automatically in the destructor.   In other words, I'd
>> like to use it like a boost::shared_ptr.
>>
>>
> This is one of the ideas that we've discussed internally.  The problem is
> that persistent carries a lot of state with it, and that state is not
> generally amenable to reference counting.  A weak handle that is reference
> counted is particularly problematic, for instance, since most weak
> callbacks dispose the handle, leaving any references to it invalid.  Unless
> you can find all copies of the handle out there, you've got a use after
> free bug waiting for you.
>
> It's much better to write a wrapper class for refcounted persistents if
> your application demands it.
>
>  --
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "v8-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/v8-users/6kSAbnUb-rQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to