+
+ bool any_finished = false;
+ while(ManagedResource *managed = front(sync_queue))
+ {
+ if(managed->state==ManagedResource::LOAD_ERROR || managed->process(true))
+ {
+ managed->finish_loading();
+ if(managed->state==ManagedResource::LOADED)
+ {
+ MutexLock lock(data_size_mutex);
+ loaded_data_size += managed->data_size;
+ }
+ any_finished = true;
+ --size;
+
+ MutexLock lock(queue_mutex);
+ sync_queue.pop_front();
+ }
+ else
+ {
+ MutexLock lock(queue_mutex);
+ bool was_empty = async_queue.empty();
+ async_queue.splice(async_queue.end(), sync_queue, sync_queue.begin());
+ if(was_empty)
+ sem.signal();
+ }
+ }
+
+ return any_finished;
+}
+
+UInt64 ResourceManager::LoadingThread::get_and_reset_loaded_data_size()
+{
+ MutexLock lock(data_size_mutex);
+ UInt64 result = loaded_data_size;
+ loaded_data_size = 0;
+ return result;