Oups, I forgot to mention something. This approach is very nice in
single threaded usage. But my situation is different. But I don't want
to take your time with these problems, because they are not really
related to cvv8, so feel free to ignore the rest of the message. You
have helped me enough already. Just in case you are interested, below
is explanation of the problem:
Basically, I will have separate isolates running in different threads,
in parallel. They will of course share the same classes. My particular
problem is the following:
I have a Socket javascript-bound class. This class, in its
constructor, takes a pointer to boolean, which is a signal for thread
termination. In this way, everything that is a blocking call monitors
this boolean location, and will abort when it is set. So in the socket
constructor, I want to pass it the address of the terminate flag of
the thread in which the context is running. So, I will need per-thread
state... I couldn't find a way to make this with the help of V8
itself, and am thinking to use a dynamic structure bound to the global
JS object, which will hold lists of all registered types (i.e.
constructors), and maps of objects for each type (in the way you do, I
just studied your code in more detail). I will also put a constructor
and destructor functor for each type, to be able to do stateful
creation and destruction.
And now I have a problem because I need to make functors of some base
type, in order to define the structure elements.