当前位置: 首页>>代码示例>>C++>>正文


C++ Isolate::Dispose方法代码示例

本文整理汇总了C++中Isolate::Dispose方法的典型用法代码示例。如果您正苦于以下问题:C++ Isolate::Dispose方法的具体用法?C++ Isolate::Dispose怎么用?C++ Isolate::Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Isolate的用法示例。


在下文中一共展示了Isolate::Dispose方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(){
  // Initialize V8.
  V8::InitializeICU();
  //V8::InitializeExternalStartupData(argv[0]);
  Platform* platform = platform::CreateDefaultPlatform();
  V8::InitializePlatform(platform);
  V8::Initialize();

  // Create a new Isolate and make it the current one.
  ArrayBufferAllocator allocator;
  Isolate::CreateParams create_params;
  create_params.array_buffer_allocator = &allocator;
  Isolate* isolate = Isolate::New(create_params);
  

  exec(isolate); 

  // Dispose the isolate and tear down V8.
  isolate->Dispose();
  V8::Dispose();
  V8::ShutdownPlatform();
  delete platform;
  return 0;

}
开发者ID:cesarvr,项目名称:v8-hacking,代码行数:25,代码来源:main.cpp

示例2: while

    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();
      }
    }
开发者ID:graememcc,项目名称:v8monkey,代码行数:15,代码来源:isolate.cpp

示例3: main

int main(int argc, char **argv) 
{
    // Initialize V8.
    V8::InitializeICU();
    Platform* platform = platform::CreateDefaultPlatform();
    V8::InitializePlatform(platform);
    V8::Initialize();

    //Quite simple, these are scope based 'managers'.
    //One protects threading issues, and one manages
    //the creation of JS handles, for clean up.

    Isolate* isolate = Isolate::New();
    {
        Isolate::Scope isolate_scope(isolate);

        // Create a stack-allocated handle scope.
        HandleScope handle_scope(isolate);

        // Create a new context.
        Local<Context> context = Context::New(isolate);

        //A context is a fresh execution context. Take for example, 
        //a browser tab or frame in Google Chrome. Each of these are
        //a new context, stamped with a global template, and created
        //on demand. When executing scripts, you can execute them in 
        //and existing context by using the Context::context_scope 
        //handlers. This 'switches' context for that execution period
        Context::Scope context_scope(context);

        //If we receive an argument, execute the script file

        if(argc > 1) {
            eScriptExecResult r = executeScript(isolate, context, string(argv[1]));
        } else {
            printf("Usage: <scriptname.js> \n Execute the javascript file.");
        }

    }

    // Dispose the isolate and tear down V8.
    isolate->Dispose();
    V8::Dispose();
    V8::ShutdownPlatform();
    delete platform;
    return 0;
}
开发者ID:marcelinol,项目名称:v8-tutorials,代码行数:47,代码来源:cli-script.cpp

示例4: isolate_scope

INT32_MAIN_INT32_ARGC_TCHAR_ARGV()
{
	GEngineLoop.PreInit(ArgC, ArgV);
	UE_LOG(LogUnrealNode, Display, TEXT("Hello World"));

	// Initialize V8.
	V8::InitializeICU();
	//V8::InitializeExternalStartupData(ArgV[0]);
	Platform* platform = platform::CreateDefaultPlatform();
	V8::InitializePlatform(platform);
	V8::Initialize();

	// Create a new Isolate and make it the current one.
	ArrayBufferAllocator allocator;
	Isolate::CreateParams create_params;
	create_params.array_buffer_allocator = &allocator;
	Isolate* isolate = Isolate::New(create_params);
	{
		Isolate::Scope isolate_scope(isolate);

		// Create a stack-allocated handle scope.
		HandleScope handle_scope(isolate);

		// Create a new context.
		Local<Context> context = Context::New(isolate);

		// Enter the context for compiling and running the hello world script.
		Context::Scope context_scope(context);

		// Create a string containing the JavaScript source code.
		Local<String> source =
			String::NewFromUtf8(isolate, "'Hello World' + ' from JavaScript'",
				NewStringType::kNormal).ToLocalChecked();

		// Compile the source code.
		Local<Script> script = Script::Compile(context, source).ToLocalChecked();

		// Run the script to get the result.
		Local<Value> result = script->Run(context).ToLocalChecked();

		// Convert the result to an UTF8 string and print it.
		String::Utf8Value utf8(result);
		printf("%s\n", *utf8);

	}

	// Dispose the isolate and tear down V8.
	isolate->Dispose();
	V8::Dispose();
	V8::ShutdownPlatform();
	delete platform;



	//uv_idle_t idler;

	//uv_idle_init(uv_default_loop(), &idler);
	//uv_idle_start(&idler, wait_for_a_while);

	//printf("Idling...\n");
	//uv_run(uv_default_loop(), UV_RUN_DEFAULT);

	//uv_loop_close(uv_default_loop());


	return 0;


}
开发者ID:nil84,项目名称:UnrealNode,代码行数:69,代码来源:UnrealNode.cpp


注:本文中的Isolate::Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。