Changeset View
Changeset View
Standalone View
Standalone View
source/scriptinterface/ScriptContext.h
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | public: | ||||
* @param parentContext Parent context from the parent thread, with which we share some thread-safe data | * @param parentContext Parent context from the parent thread, with which we share some thread-safe data | ||||
* @param contextSize Maximum size in bytes of the new context | * @param contextSize Maximum size in bytes of the new context | ||||
* @param heapGrowthBytesGCTrigger Size in bytes of cumulated allocations after which a GC will be triggered | * @param heapGrowthBytesGCTrigger Size in bytes of cumulated allocations after which a GC will be triggered | ||||
*/ | */ | ||||
static shared_ptr<ScriptContext> CreateContext( | static shared_ptr<ScriptContext> CreateContext( | ||||
int contextSize = DEFAULT_CONTEXT_SIZE, | int contextSize = DEFAULT_CONTEXT_SIZE, | ||||
int heapGrowthBytesGCTrigger = DEFAULT_HEAP_GROWTH_BYTES_GCTRIGGER); | int heapGrowthBytesGCTrigger = DEFAULT_HEAP_GROWTH_BYTES_GCTRIGGER); | ||||
/** | /** | ||||
* MaybeIncrementalGC tries to determine whether a context-wide garbage collection would free up enough memory to | * MaybeIncrementalGC tries to determine whether a context-wide garbage collection would free up enough memory to | ||||
* be worth the amount of time it would take. It does this with our own logic and NOT some predefined JSAPI logic because | * be worth the amount of time it would take. It does this with our own logic and NOT some predefined JSAPI logic because | ||||
* such functionality currently isn't available out of the box. | * such functionality currently isn't available out of the box. | ||||
* It does incremental GC which means it will collect one slice each time it's called until the garbage collection is done. | * It does incremental GC which means it will collect one slice each time it's called until the garbage collection is done. | ||||
* This can and should be called quite regularly. The delay parameter allows you to specify a minimum time since the last GC | * This can and should be called quite regularly. The delay parameter allows you to specify a minimum time since the last GC | ||||
* in seconds (the delay should be a fraction of a second in most cases though). | * in seconds (the delay should be a fraction of a second in most cases though). | ||||
* It will only start a new incremental GC or another GC slice if this time is exceeded. The user of this function is | * It will only start a new incremental GC or another GC slice if this time is exceeded. The user of this function is | ||||
Show All 10 Lines | public: | ||||
JSRuntime* GetJSRuntime() const { return m_rt; } | JSRuntime* GetJSRuntime() const { return m_rt; } | ||||
/** | /** | ||||
* GetGeneralJSContext returns the context without starting a GC request and without | * GetGeneralJSContext returns the context without starting a GC request and without | ||||
* entering any compartment. It should only be used in specific situations, such as | * entering any compartment. It should only be used in specific situations, such as | ||||
* creating a new compartment, or as an unsafe alternative to GetJSRuntime. | * creating a new compartment, or as an unsafe alternative to GetJSRuntime. | ||||
* If you need the compartmented context of a ScriptInterface, you should create a | * If you need the compartmented context of a ScriptInterface, you should create a | ||||
* ScriptInterface::Request and use the context from that. | * ScriptRequest and use the context from that. | ||||
*/ | */ | ||||
JSContext* GetGeneralJSContext() const { return m_cx; } | JSContext* GetGeneralJSContext() const { return m_cx; } | ||||
private: | private: | ||||
JSRuntime* m_rt; | JSRuntime* m_rt; | ||||
JSContext* m_cx; | JSContext* m_cx; | ||||
Show All 10 Lines |
Wildfire Games · Phabricator