| 163 | } |
| 164 | |
| 165 | void ContentService::Update() |
| 166 | { |
| 167 | PROFILE_CPU(); |
| 168 | |
| 169 | #if PLATFORM_THREADS_LIMIT == 1 |
| 170 | // Run content-streaming tasks on a main thread |
| 171 | if (LoadTasks.HasItems()) |
| 172 | { |
| 173 | double timeLimit = 0.01; // 10ms |
| 174 | double startTime = Platform::GetTimeSeconds(); |
| 175 | do |
| 176 | { |
| 177 | auto task = LoadTasks[0]; |
| 178 | LoadTasks.RemoveAt(0); |
| 179 | MainLoadThread->Run(task); |
| 180 | } while (LoadTasks.HasItems() && Platform::GetTimeSeconds() - startTime < timeLimit); |
| 181 | } |
| 182 | #endif |
| 183 | |
| 184 | // Broadcast `OnLoaded` events |
| 185 | LoadedAssetsToInvokeLocker.Lock(); |
| 186 | while (LoadedAssetsToInvoke.HasItems()) |
| 187 | { |
| 188 | auto asset = LoadedAssetsToInvoke.Dequeue(); |
| 189 | asset->onLoaded_MainThread(); |
| 190 | #if USE_EDITOR |
| 191 | Content::onAddDependencies(asset); |
| 192 | #endif |
| 193 | } |
| 194 | LoadedAssetsToInvokeLocker.Unlock(); |
| 195 | } |
| 196 | |
| 197 | void ContentService::LateUpdate() |
| 198 | { |