Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/scriptinterface/ScriptRuntime.h
/* Copyright (C) 2018 Wildfire Games. | /* Copyright (C) 2020 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | public: | ||||
* responsible for ensuring that GC can run with a small enough delay to get done with the work. | * responsible for ensuring that GC can run with a small enough delay to get done with the work. | ||||
*/ | */ | ||||
void MaybeIncrementalGC(double delay); | void MaybeIncrementalGC(double delay); | ||||
void ShrinkingGC(); | void ShrinkingGC(); | ||||
void RegisterContext(JSContext* cx); | void RegisterContext(JSContext* cx); | ||||
void UnRegisterContext(JSContext* cx); | void UnRegisterContext(JSContext* cx); | ||||
/** | |||||
* Registers an object to be freed/finalized by the ScriptRuntime. Freeing is | |||||
* guaranteed to happen after the next minor GC has completed, but might also | |||||
* happen a bit later. This is only needed in very special situations | |||||
* and you should only use it if you know exactly why you need it! | |||||
* Specify a deleter for the shared_ptr to free the void pointer correctly | |||||
* (by casting to the right type before calling delete for example). | |||||
*/ | |||||
void AddDeferredFinalizationObject(const std::shared_ptr<void>& obj); | |||||
JSRuntime* m_rt; | JSRuntime* m_rt; | ||||
private: | private: | ||||
void PrepareContextsForIncrementalGC(); | void PrepareContextsForIncrementalGC(); | ||||
void GCCallbackMember(); | |||||
std::list<JSContext*> m_Contexts; | std::list<JSContext*> m_Contexts; | ||||
std::vector<std::shared_ptr<void> > m_FinalizationListObjectIdCache; | |||||
int m_RuntimeSize; | int m_RuntimeSize; | ||||
int m_HeapGrowthBytesGCTrigger; | int m_HeapGrowthBytesGCTrigger; | ||||
int m_LastGCBytes; | int m_LastGCBytes; | ||||
double m_LastGCCheck; | double m_LastGCCheck; | ||||
static void GCCallback(JSRuntime *rt, JSGCStatus status, void *data); | |||||
}; | }; | ||||
#endif // INCLUDED_SCRIPTRUNTIME | #endif // INCLUDED_SCRIPTRUNTIME |
Wildfire Games · Phabricator