+ ++size;
+}
+
+void ResourceManager::LoadingThread::remove_resource(ManagedResource &r)
+{
+ while(!try_remove_resource(r))
+ Time::sleep(Time::msec);
+
+ r.finish_loading();
+ if(r.state==ManagedResource::LOADED)
+ {
+ MutexLock lock(data_size_mutex);
+ loaded_data_size += r.data_size;
+ }
+}
+
+bool ResourceManager::LoadingThread::try_remove_resource(ManagedResource &r)
+{
+ MutexLock lock(queue_mutex);
+
+ LoadQueue::iterator i = find(async_queue.begin(), async_queue.end(), &r);
+ if(i==async_queue.end())
+ {
+ i = find(sync_queue.begin(), sync_queue.end(), &r);
+ if(i!=sync_queue.end())
+ {
+ sync_queue.erase(i);
+ --size;
+ }
+ }
+ else if(i==async_queue.begin())
+ return false;
+ else