Hi,
We've been working on migration of existing wrapper classes in Node.js to use cppgc::GargageCollected, and ran into some questions regarding what can be done in the destructors. The conditions of the destructors don't seem to be very clear from the headers, so asking here for some clarification.
1. Is the destructor of cppgc::GargageCollected always called in the thread where they are created? It also seems possible for them to be called from platform worker threads? In the case where there's no guarantee about this, is the recommendation to use prefinalizers to make sure clean up is performed on the creation thread?
2. Is it okay to dereference v8::TracedReference held by a cppgc::GargageCollected in its destructor? Are they guaranteed to be still valid at that point?
3. It seems trying to mutate the heap from a cppgc::GargageCollected destructor (e.g. set internal pointers of an object, so I'd assume calling into JS or allocating objects would be even more forbidden) would result in a crash. Is that something that should not be done, or is there way to do it properly? Is it safe to do these from prefinalizers instead?
Appreciate any answers we can get, thanks!