Skip to content

Instantly share code, notes, and snippets.

@groundwater
Created August 9, 2013 21:58
Show Gist options
  • Save groundwater/6197639 to your computer and use it in GitHub Desktop.
Save groundwater/6197639 to your computer and use it in GitHub Desktop.
[14:50:32] trevnorris: groundwater: there are others that are "safer", whatever that's about :P
[14:50:41] trevnorris: but still almost as fast
[14:51:10] trevnorris: groundwater: are you creating an object just to attach these objects?
[14:51:38] groundwater: i will be
[14:51:43] trevnorris flogs github
[14:52:02] groundwater: right now i'm actually converting between c++ / js land but that's proving to be a losing strategy
[14:52:47] groundwater: and i'm just playing around with various approaches to find the best fit
[14:52:59] trevnorris: groundwater: then the actual proper way to do this is create an ObjectTemplate, set the InternalFieldCount = 1
[14:53:21] trevnorris: then use SetAlignedPointerInInternalfield
[14:53:43] trevnorris: oy, again. SetAlignedPointerInInternalField (int index, void *value)
[14:53:53] groundwater: awesome
[14:54:20] trevnorris: yeah, use the ObjectTemplate to create your new objects, then you can store as many pointers on the object as you want
[14:54:36] groundwater: same question as before, is there a callback i can register for when the object is reaped by teh GC?
[14:54:43] trevnorris: use GetAlignedPointerFromInternalField to get the pointer out
[14:55:15] trevnorris: for that you need to Persistant the object you create, then set the weak callback
[14:55:24] trevnorris: you can see an example in master src/smalloc.cc
[14:55:34] groundwater: okay, yah tjfontaine showed me that example
[14:56:15] trevnorris: yeah, that's actually the only way to accomplish that. no performance tricks around that crap
[14:56:24] groundwater: thanks, this is great
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment