AutoIsolateCleanup::~AutoIsolateCleanup() { while (Isolate::GetCurrent()) { // Isolates can be entered multiple times Isolate* i {Isolate::GetCurrent()}; //internal::Isolate* ii {internal::Isolate::FromAPIIsolate(i)}; //V8MONKEY_ASSERT(!ii->IsLockedForThisThread(), "An isolate was still locked"); while (Isolate::GetCurrent() == i) { i->Exit(); } i->Dispose(); } }
/* * 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 (); }