| 262 | } |
| 263 | |
| 264 | void ContentService::Dispose() |
| 265 | { |
| 266 | IsExiting = true; |
| 267 | |
| 268 | // Save assets registry before engine closing |
| 269 | Cache.Save(); |
| 270 | |
| 271 | // Flush objects (some asset-related objects/references may be pending to delete) |
| 272 | ObjectsRemovalService::Flush(); |
| 273 | |
| 274 | // Unload all remaining assets |
| 275 | { |
| 276 | ScopeLock lock(AssetsLocker); |
| 277 | |
| 278 | for (auto i = Assets.Begin(); i.IsNotEnd(); ++i) |
| 279 | { |
| 280 | i->Value->DeleteObject(); |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | // Flush objects (some assets may be pending to delete) |
| 285 | ObjectsRemovalService::Flush(); |
| 286 | |
| 287 | // NOW dispose graphics device - where there is no loaded assets at all |
| 288 | Graphics::DisposeDevice(); |
| 289 | |
| 290 | #if PLATFORM_THREADS_LIMIT > 1 |
| 291 | // Exit all load threads |
| 292 | for (auto thread : LoadThreads) |
| 293 | thread->NotifyExit(); |
| 294 | LoadTasksSignal.NotifyAll(); |
| 295 | for (auto thread : LoadThreads) |
| 296 | thread->Join(); |
| 297 | LoadThreads.ClearDelete(); |
| 298 | #endif |
| 299 | Delete(MainLoadThread); |
| 300 | MainLoadThread = nullptr; |
| 301 | ThisLoadThread = nullptr; |
| 302 | |
| 303 | #if PLATFORM_THREADS_LIMIT > 1 |
| 304 | // Cancel all remaining tasks (no chance to execute them) |
| 305 | LoadTasks.CancelAll(); |
| 306 | #else |
| 307 | for (auto* e : LoadTasks) |
| 308 | e->Cancel(); |
| 309 | LoadTasks.Clear(); |
| 310 | LoadTasks.SetCapacity(0); |
| 311 | #endif |
| 312 | } |
| 313 | |
| 314 | IAssetFactory::Collection& IAssetFactory::Get() |
| 315 | { |
nothing calls this directly
no test coverage detected