Holding v8:Persistent handles

230 views
Skip to first unread message

Michael Cullen

unread,
Jul 31, 2013, 8:47:48 PM7/31/13
to v8-u...@googlegroups.com
Hi,

I've been looking at weak persistent handles, and came across this blog post (already referenced in a recent post here: http://create.tpsitulsa.com/blog/2009/01/29/v8-objects/)

With all the changes going on within Persistent, I was wondering what the best way to store the weak handles is? std::map requires the object to be copyable, which Persistent doesn't seem to be unless you define V8_USE_UNSAFE_HANDLES.

I did see a reference to the new Persistent being copyable and capable of being stored in various datatypes - how will this work?

Michael

Michael Cullen

unread,
Jul 31, 2013, 9:42:12 PM7/31/13
to v8-u...@googlegroups.com
Sorry, actually meant this post: http://create.tpsitulsa.com/wiki/V8/Persistent_Handles

Dan Carney

unread,
Aug 1, 2013, 3:31:15 AM8/1/13
to v8-u...@googlegroups.com
There are a couple of workarounds until all the changes to persistent are done:

  • Simply use V8_USE_UNSAFE_HANDLES and make sure your map isn't itself being copied.
  • Do what we did in Blink with UnsafePersistent and DomWrapperMap - note that we will eventually get rid of UnsafePersistent in favour of the newly defined Persistent
eventually, we want a copyable version of Persistent as well as something like a std::unique_ptr version for use in certain types of collections

Mike Moening

unread,
Aug 1, 2013, 11:04:39 AM8/1/13
to v8-u...@googlegroups.com
Dan, 
When do you think the Persistent changes will be complete??
Its hard to wait.  Without all the features in there it's hard to use.
Sort of a mine field...

Dan Carney

unread,
Aug 1, 2013, 1:00:40 PM8/1/13
to v8-u...@googlegroups.com
Sort of a mine field...

 
It absolutely is.  This was delayed several weeks by most of the team being on vacation, but we're back and picking it up again right now.  It'll probably still take a couple of weeks to get everything in.

Mike Moening

unread,
Aug 2, 2013, 1:11:52 PM8/2/13
to v8-u...@googlegroups.com
Good. 
Will we be able to copy persistent?  In my case I have to be able to pass around a persistent and store it in several places at a time.
Or should I wrap it in another object and ref count it myself?

On Thu, Aug 1, 2013 at 12:00 PM, Dan Carney <dca...@chromium.org> wrote:
Sort of a mine field...

 
It absolutely is.  This was delayed several weeks by most of the team being on vacation, but we're back and picking it up again right now.  It'll probably still take a couple of weeks to get everything in.

--
--
v8-users mailing list
v8-u...@googlegroups.com
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/1RgrPNYKVyY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to v8-users+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dan Carney

unread,
Aug 5, 2013, 3:01:12 AM8/5/13
to v8-u...@googlegroups.com
Good. 
Will we be able to copy persistent?  In my case I have to be able to pass around a persistent and store it in several places at a time.
Or should I wrap it in another object and ref count it myself?

It will be copyable, but copying will become more expensive, as the backing store needs to be copied.

Ben Noordhuis

unread,
Aug 5, 2013, 5:38:38 AM8/5/13
to v8-u...@googlegroups.com
As a counterpoint, I like that Persistent<T> is non-copyable now. It
makes it much easier to reason about its life cycle and ownership. I
would move to keep it like this.

Dan Carney

unread,
Aug 5, 2013, 7:00:24 AM8/5/13
to v8-u...@googlegroups.com
We like it too, which is why we are planning on having a second template parameter for persistent, a traits class, which will control whether a handle is copyable, etc.  We're undecided on what the default template parameter will be, but at first it will have to implement the current semantics to keep things sane.
Reply all
Reply to author
Forward
0 new messages