| 772 | } |
| 773 | |
| 774 | void 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 | |
| 812 | asCScriptEngine::~asCScriptEngine() |
| 813 | { |
no test coverage detected