MCPcopy Create free account
hub / github.com/anjo76/angelscript / DeleteDiscardedModules

Method DeleteDiscardedModules

sdk/angelscript/source/as_scriptengine.cpp:774–810  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

772}
773
774void asCScriptEngine::DeleteDiscardedModules()
775{
776 // TODO: redesign: Prevent more than one thread from entering this function at the same time.
777 // If a thread is already doing the work for the clean-up the other thread should
778 // simply return, as the first thread will continue.
779
780 ACQUIRESHARED(engineRWLock);
781 asUINT maxCount = discardedModules.GetLength();
782 RELEASESHARED(engineRWLock);
783
784 for( asUINT n = 0; n < maxCount; n++ )
785 {
786 ACQUIRESHARED(engineRWLock);
787 asCModule *mod = discardedModules[n];
788 RELEASESHARED(engineRWLock);
789
790 if( !mod->HasExternalReferences(shuttingDown) )
791 {
792 asDELETE(mod, asCModule);
793 n--;
794 }
795
796 ACQUIRESHARED(engineRWLock);
797 // Determine the max count again, since another module may have been discarded during the processing
798 maxCount = discardedModules.GetLength();
799 RELEASESHARED(engineRWLock);
800 }
801
802 // Go over the list of global properties, to see if it is possible to clean
803 // up some variables that are no longer referred to by any functions
804 for( asUINT n = 0; n < globalProperties.GetLength(); n++ )
805 {
806 asCGlobalProperty *prop = globalProperties[n];
807 if( prop && prop->refCount.get() == 1 )
808 RemoveGlobalProperty(prop);
809 }
810}
811
812asCScriptEngine::~asCScriptEngine()
813{

Callers 1

DiscardMethod · 0.80

Calls 3

HasExternalReferencesMethod · 0.80
GetLengthMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected