I would like to cache Persistent handles in such a way that I can retrieve 
the same Persistent instance given the identical JS object, i.e. imagine a 
function like so:

Persistent<Object> GetPersistentForObject(Local<Object> obj)
{
   // If we have already created a Persistent for obj, find and return it.
   // Otherwise, create and return a Persistent for obj and cache it for 
   // future calls.
}

The obvious thought is to store the Persistent handles in a map of some 
kind, but what to use as the key? I assume it would not be possible to 
actually use Local handles as keys in a map that outlives the current 
HandleScope.

One thought I had was to assign a unique integer to the object using 
obj.SetPrivate(...), and use that as the key, but SetPrivate is documented 
as experimental, which is discouraging.

Is there an easier way to achieve what I'm trying to do? I feel like I may 
be missing something obvious...

Jonathan


-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
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 v8-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/197b2711-31c2-4c88-91d4-6119f0edc37an%40googlegroups.com.

Reply via email to