| 1031 | } |
| 1032 | |
| 1033 | void DeletePreloader(HPreloader preloader) |
| 1034 | { |
| 1035 | // Since Preload calls need their Create calls done and PostCreate calls must always follow Create calls. |
| 1036 | // To fix this: |
| 1037 | // * Make Get calls insta-fail on RESULT_ABORTED or something |
| 1038 | // * Make Queue only return RESULT_ABORTED always. |
| 1039 | // This is not a super-important use-case, the only way to trigger this is to start a load and |
| 1040 | // then do unload before it completes or if you destroy the collection while loading. |
| 1041 | // The normal operation is to issue a load and progress once complete. |
| 1042 | while (UpdatePreloader(preloader, 0, 0, 1000000) == RESULT_PENDING) |
| 1043 | { |
| 1044 | dmLogWarning("Waiting for preloader to complete."); |
| 1045 | } |
| 1046 | |
| 1047 | // Release root and persisted resources |
| 1048 | preloader->m_PersistedResources.Push(preloader->m_Request[0].m_Resource); |
| 1049 | for (uint32_t i = 0; i < preloader->m_PersistedResources.Size(); ++i) |
| 1050 | { |
| 1051 | void* resource = preloader->m_PersistedResources[i]; |
| 1052 | if (!resource) |
| 1053 | continue; |
| 1054 | Release(preloader->m_Factory, resource); |
| 1055 | } |
| 1056 | |
| 1057 | assert(preloader->m_FreelistSize == (MAX_PRELOADER_REQUESTS - 1)); |
| 1058 | dmLoadQueue::DeleteQueue(preloader->m_LoadQueue); |
| 1059 | |
| 1060 | dmBlockAllocator::DeleteContext(preloader->m_BlockAllocator); |
| 1061 | |
| 1062 | dmSpinlock::Destroy(&preloader->m_SyncedDataSpinlock); |
| 1063 | delete preloader; |
| 1064 | } |
| 1065 | |
| 1066 | bool PreloadHint(HResourcePreloadHintInfo info, const char* name) |
| 1067 | { |