本文整理汇总了C++中Isolate::Enter方法的典型用法代码示例。如果您正苦于以下问题:C++ Isolate::Enter方法的具体用法?C++ Isolate::Enter怎么用?C++ Isolate::Enter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Isolate
的用法示例。
在下文中一共展示了Isolate::Enter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: jniScope
/*
* Class: org_appcelerator_kroll_runtime_v8_V8Runtime
* Method: nativeInit
* Signature: (Lorg/appcelerator/kroll/runtime/v8/V8Runtime;)J
*/
JNIEXPORT void JNICALL Java_org_appcelerator_kroll_runtime_v8_V8Runtime_nativeInit(JNIEnv *env, jobject self, jboolean useGlobalRefs, jobject debugger, jboolean DBG, jboolean profilerEnabled)
{
if (!V8Runtime::initialized) {
// Initialize V8.
V8::InitializeICU();
// TODO Enable this when we use snapshots?
//V8::InitializeExternalStartupData(argv[0]);
V8Runtime::platform = platform::CreateDefaultPlatform();
V8::InitializePlatform(V8Runtime::platform);
V8::Initialize();
V8Runtime::initialized = true;
}
if (profilerEnabled) {
char* argv[] = { const_cast<char*>(""), const_cast<char*>("--expose-gc") };
int argc = sizeof(argv)/sizeof(*argv);
V8::SetFlagsFromCommandLine(&argc, argv, false);
}
titanium::JNIScope jniScope(env);
JavaObject::useGlobalRefs = useGlobalRefs;
V8Runtime::DBG = DBG;
V8Runtime::javaInstance = env->NewGlobalRef(self);
JNIUtil::initCache();
Isolate* isolate;
if (V8Runtime::v8_isolate == nullptr) {
// Create a new Isolate and make it the current one.
Isolate::CreateParams create_params;
create_params.array_buffer_allocator = &allocator;
isolate = Isolate::New(create_params);
isolate->Enter();
V8Runtime::v8_isolate = isolate;
// Log all uncaught V8 exceptions.
V8::AddMessageListener(&logV8Exception);
V8::SetCaptureStackTraceForUncaughtExceptions(true);
} else {
isolate = V8Runtime::v8_isolate;
isolate->Enter();
}
HandleScope scope(isolate);
Local<Context> context = Context::New(isolate);
context->Enter();
V8Runtime::globalContext.Reset(isolate, context);
JSDebugger::init(env, isolate, debugger);
if (debugger != nullptr) {
V8Runtime::debuggerEnabled = true;
}
V8Runtime::bootstrap(context);
LOG_HEAP_STATS(isolate, TAG);
}
示例2: jniScope
/*
* Class: org_appcelerator_kroll_runtime_v8_V8Runtime
* Method: nativeInit
* Signature: (Lorg/appcelerator/kroll/runtime/v8/V8Runtime;)J
*/
JNIEXPORT void JNICALL Java_org_appcelerator_kroll_runtime_v8_V8Runtime_nativeInit(JNIEnv *env, jobject self, jboolean useGlobalRefs, jobject debugger, jboolean DBG, jboolean profilerEnabled)
{
if (!V8Runtime::initialized) {
// Initialize V8.
V8::InitializeICU();
// TODO Enable this when we use snapshots?
//V8::InitializeExternalStartupData(argv[0]);
V8Runtime::platform = platform::CreateDefaultPlatform();
V8::InitializePlatform(V8Runtime::platform);
V8::Initialize();
V8Runtime::initialized = true;
}
titanium::JNIScope jniScope(env);
JavaObject::useGlobalRefs = useGlobalRefs;
V8Runtime::DBG = DBG;
V8Runtime::javaInstance = env->NewGlobalRef(self);
JNIUtil::initCache();
Isolate* isolate;
if (V8Runtime::v8_isolate == nullptr) {
// Create a new Isolate and make it the current one.
Isolate::CreateParams create_params;
create_params.array_buffer_allocator = &allocator;
isolate = Isolate::New(create_params);
isolate->Enter();
V8Runtime::v8_isolate = isolate;
// Log all uncaught V8 exceptions.
isolate->AddMessageListener(logV8Exception);
// isolate->SetAbortOnUncaughtExceptionCallback(ShouldAbortOnUncaughtException);
// isolate->SetAutorunMicrotasks(false);
// isolate->SetFatalErrorHandler(OnFatalError);
isolate->SetCaptureStackTraceForUncaughtExceptions(true, 10, v8::StackTrace::kOverview);
} else {
isolate = V8Runtime::v8_isolate;
isolate->Enter();
}
HandleScope scope(isolate);
Local<Context> context = Context::New(isolate);
context->Enter();
V8Runtime::globalContext.Reset(isolate, context);
JSDebugger::init(env, debugger, context);
if (debugger != nullptr) {
V8Runtime::debuggerEnabled = true;
}
V8Runtime::bootstrap(context);
LOG_HEAP_STATS(isolate, TAG);
}
示例3: atexit
bool V8::Initialize() {
Isolate *isolate = Isolate::New();
isolate->Enter();
atexit([]() {
Isolate::GetCurrent()->Dispose();
});
return true;
}
示例4: ul
/*
* Prototype:
* Thread.sleep(delay)
*
* Docs:
* TBW
*
* Example:
* TBW
*/
static void
gum_script_thread_on_sleep (const FunctionCallbackInfo<Value> & info)
{
Isolate * isolate = info.GetIsolate ();
Local<Value> delay_val = info[0];
if (!delay_val->IsNumber ())
{
isolate->ThrowException (Exception::TypeError (String::NewFromUtf8 (isolate,
"Thread.sleep: argument must be a number specifying delay")));
return;
}
double delay = delay_val->ToNumber ()->Value ();
isolate->Exit ();
{
Unlocker ul (isolate);
g_usleep (delay * G_USEC_PER_SEC);
}
isolate->Enter ();
}