i32 IResourceManager::ManageUnusedResources()
 {
     // Clear resources and move them to unused buffer
     i32 iResult = XST_OK;
     ForEachResource( [&] (ResourceWeakPtr pRes, GroupWeakPtr pGroup) 
     {
         if( pRes->GetRefCount() > 1 ) // branch prediction, most of resources should be used (ref count > 1 )
             return;
         else // if this is the last reference = it exists and is used only in its group
         {
             ul32 ulHandle = pRes->GetResourceHandle();
             if( pRes->ClearResource() == XST_OK )
                 m_sUnusedResources.push( pGroup->RemoveResource( ulHandle ) );
             else
                 iResult = XST_FAIL;
         }
     });
     return iResult;
 }
Esempio n. 2
0
void SaveResources(void)
{
	ForEachResource(SaveEachResource);
}