Using Google's v8 c++ library, I am wanting to create a context where I have several templates, variables, and globals defined and ready for use by several places in code that may run on different threads, each with its own isolate, where they should also each have their own local copy of the context so that any changes to the global variables in one thread will not impact the others.
I can do this by explicitly setting up all my templates, variables, and globals each and every time I want a new context, but I am wondering if there is a more efficient way. Assume that I already have a global v8::Isolate pointer and v8::Persistent that represent the master state. What do I then need to do, if I want to create a brand new isolate in its own thread,and make a new context that is essentially a clone of the master? I know I can wrap a mutex around accesses to the master to ensure that different threads do not access it at the same time if necessary. I just don't know how to efficiently copy information that was made in one isolate to another without recreating its entire contents from scratch.