C# 클래스 MsieJavaScriptEngine.JsRt.JavaScriptRuntime

A Chakra runtime.

Each Chakra runtime has its own independent execution engine, JIT compiler, and garbage collected heap. As such, each runtime is completely isolated from other runtimes.

Runtimes can be used on any thread, but only one thread can call into a runtime at any time.

NOTE: A JavaScriptRuntime, unlike other objects in the Chakra hosting API, is not garbage collected since it contains the garbage collected heap itself. A runtime will continue to exist until Dispose is called.

파일 보기 프로젝트 열기: klumsy/PowerShellJS 1 사용 예제들

공개 메소드들

메소드 설명
CollectGarbage ( ) : void

Performs a full garbage collection.

Create ( ) : JavaScriptRuntime

Creates a new runtime.

Create ( JavaScriptRuntimeAttributes attributes, JavaScriptRuntimeVersion version ) : JavaScriptRuntime

Creates a new runtime.

Create ( JavaScriptRuntimeAttributes attributes, JavaScriptRuntimeVersion version, JavaScriptThreadServiceCallback threadServiceCallback ) : JavaScriptRuntime

Creates a new runtime.

CreateContext ( ) : JavaScriptContext

Creates a script context for running scripts.

Each script context has its own global object that is isolated from all other script contexts.

CreateContext ( Native debugApplication ) : JavaScriptContext

Creates a debug script context for running scripts.

Each script context has its own global object that is isolated from all other script contexts.

Dispose ( ) : void

Disposes a runtime.

Once a runtime has been disposed, all resources owned by it are invalid and cannot be used. If the runtime is active (i.e. it is set to be current on a particular thread), it cannot be disposed.

SetBeforeCollectCallback ( IntPtr callbackState, JavaScriptBeforeCollectCallback beforeCollectCallback ) : void

Sets a callback function that is called by the runtime before garbage collection.

The callback is invoked on the current runtime execution thread, therefore execution is blocked until the callback completes.

The callback can be used by hosts to prepare for garbage collection. For example, by releasing unnecessary references on Chakra objects.

SetMemoryAllocationCallback ( IntPtr callbackState, JavaScriptMemoryAllocationCallback allocationCallback ) : void

Sets a memory allocation callback for specified runtime

Registering a memory allocation callback will cause the runtime to call back to the host whenever it acquires memory from, or releases memory to, the OS. The callback routine is called before the runtime memory manager allocates a block of memory. The allocation will be rejected if the callback returns false. The runtime memory manager will also invoke the callback routine after freeing a block of memory, as well as after allocation failures.

The callback is invoked on the current runtime execution thread, therefore execution is blocked until the callback completes.

The return value of the callback is not stored; previously rejected allocations will not prevent the runtime from invoking the callback again later for new memory allocations.

메소드 상세

CollectGarbage() 공개 메소드

Performs a full garbage collection.
public CollectGarbage ( ) : void
리턴 void

Create() 공개 정적인 메소드

Creates a new runtime.
public static Create ( ) : JavaScriptRuntime
리턴 JavaScriptRuntime

Create() 공개 정적인 메소드

Creates a new runtime.
public static Create ( JavaScriptRuntimeAttributes attributes, JavaScriptRuntimeVersion version ) : JavaScriptRuntime
attributes JavaScriptRuntimeAttributes The attributes of the runtime to be created.
version JavaScriptRuntimeVersion The version of the runtime to be created.
리턴 JavaScriptRuntime

Create() 공개 정적인 메소드

Creates a new runtime.
public static Create ( JavaScriptRuntimeAttributes attributes, JavaScriptRuntimeVersion version, JavaScriptThreadServiceCallback threadServiceCallback ) : JavaScriptRuntime
attributes JavaScriptRuntimeAttributes The attributes of the runtime to be created.
version JavaScriptRuntimeVersion The version of the runtime to be created.
threadServiceCallback JavaScriptThreadServiceCallback The thread service for the runtime. Can be null.
리턴 JavaScriptRuntime

CreateContext() 공개 메소드

Creates a script context for running scripts.
Each script context has its own global object that is isolated from all other script contexts.
public CreateContext ( ) : JavaScriptContext
리턴 JavaScriptContext

CreateContext() 공개 메소드

Creates a debug script context for running scripts.
Each script context has its own global object that is isolated from all other script contexts.
public CreateContext ( Native debugApplication ) : JavaScriptContext
debugApplication Native The debug application to use.
리턴 JavaScriptContext

Dispose() 공개 메소드

Disposes a runtime.
Once a runtime has been disposed, all resources owned by it are invalid and cannot be used. If the runtime is active (i.e. it is set to be current on a particular thread), it cannot be disposed.
public Dispose ( ) : void
리턴 void

SetBeforeCollectCallback() 공개 메소드

Sets a callback function that is called by the runtime before garbage collection.

The callback is invoked on the current runtime execution thread, therefore execution is blocked until the callback completes.

The callback can be used by hosts to prepare for garbage collection. For example, by releasing unnecessary references on Chakra objects.

public SetBeforeCollectCallback ( IntPtr callbackState, JavaScriptBeforeCollectCallback beforeCollectCallback ) : void
callbackState System.IntPtr /// User provided state that will be passed back to the callback. ///
beforeCollectCallback JavaScriptBeforeCollectCallback The callback function being set.
리턴 void

SetMemoryAllocationCallback() 공개 메소드

Sets a memory allocation callback for specified runtime

Registering a memory allocation callback will cause the runtime to call back to the host whenever it acquires memory from, or releases memory to, the OS. The callback routine is called before the runtime memory manager allocates a block of memory. The allocation will be rejected if the callback returns false. The runtime memory manager will also invoke the callback routine after freeing a block of memory, as well as after allocation failures.

The callback is invoked on the current runtime execution thread, therefore execution is blocked until the callback completes.

The return value of the callback is not stored; previously rejected allocations will not prevent the runtime from invoking the callback again later for new memory allocations.

public SetMemoryAllocationCallback ( IntPtr callbackState, JavaScriptMemoryAllocationCallback allocationCallback ) : void
callbackState System.IntPtr /// User provided state that will be passed back to the callback. ///
allocationCallback JavaScriptMemoryAllocationCallback /// Memory allocation callback to be called for memory allocation events. ///
리턴 void