instance internally creates one V8 isolate and one V8 context, although we're hoping to make this more configurable in the future. The current design has the following implications for your scenarios:
Scenario 1 is supported.
Scenario 2 is supported. If your contexts are sharing data that is not thread-safe, you must protect it by implementing your own locks.
Scenario 3 is supported, but only one thread at a time will be allowed into the script engine. The
test (source code
) uses 256 threads to remove 256 items from a list held by one V8 context.
Scenario 4 is supported, but you must maintain your own well-defined lock ordering in order to avoid deadlock. You don't have to implement your own locks (unless, again, your contexts are sharing data that is not thread-safe), but you must make sure that Context
A doesn't try to call Context B while Context B is trying to call Context A.
Thanks for your question!