I have 2 modules that initialize an isolate. As part of a feature, I connect them simultaneously to be able to switch between them. Can they exist like this if when executing code on one isolate, the second one is idle and vice versa
in both cases similar creation and storage
namespace executor_old
{
using StartupDataPtr = std::unique_ptr< v8::StartupData, std::function< void( v8::StartupData* ) > >;
thread_local IsolatePtr ThreadIsolate;
namespace executor_new::core
{
using StartupDataPtr = std::unique_ptr< v8::StartupData, std::function< void( v8::StartupData* ) > >;
IsolatePtr& GetThreadIsolate()
{
static thread_local IsolatePtr THREAD_ISOLATE;
return THREAD_ISOLATE;
}
IsolatePtr GetThreadIsolateInstance()
{
if( GetThreadIsolate() != nullptr )
return GetThreadIsolate();
v8::Isolate* isolate;
v8::Isolate::CreateParams create_params;
{
log::ScopedLogInterval<> logger( L"[ejs] new allocator" );
create_params.array_buffer_allocator_shared =
std::shared_ptr< v8::ArrayBuffer::Allocator >{ v8::ArrayBuffer::Allocator::NewDefaultAllocator() };
create_params.snapshot_blob = IsolateStartupSnapshot::GetInstance().Get();
}
{
log::ScopedLogInterval<> logger( L"[ejs] new isolate" );
isolate = v8::Isolate::New( create_params );
}
{
log::ScopedLogInterval<> logger( L"[ejs] isolate initialize" );
isolate->SetFatalErrorHandler( FatalErrorCallback );
isolate->SetOOMErrorHandler( OOMErrorCallback );
GetThreadIsolate() = IsolatePtr( isolate, DisposeIsolate );
}
return GetThreadIsolate();
}
I have 2 modules that initialize an isolate. As part of a feature, I connect them simultaneously to be able to switch between them. Can they exist like this if when executing code on one isolate, the second one is idle and vice versa
in both cases similar creation and storage