| 242 | } |
| 243 | |
| 244 | void ResourceManager::complete_requests() |
| 245 | { |
| 246 | ResourceRequest rr; |
| 247 | while (_resource_loader->_loaded.pop(rr)) { |
| 248 | if (rr.type == RESOURCE_TYPE_PACKAGE || rr.type == RESOURCE_TYPE_CONFIG || _autoload) { |
| 249 | // Always add packages and configs to the resource map because they never have |
| 250 | // requirements and are never required by any resource, hence no online() order |
| 251 | // constraints apply. |
| 252 | resource_manager_internal::add_resource(*this |
| 253 | , rr.package_name |
| 254 | , rr.type |
| 255 | , rr.name |
| 256 | , rr.allocator |
| 257 | , rr.data |
| 258 | ); |
| 259 | } else { |
| 260 | ResourcePair rp { RESOURCE_TYPE_PACKAGE, rr.package_name }; |
| 261 | ResourceData &pkg_data = hash_map::get(_resources, rp, ResourceData::NOT_FOUND); |
| 262 | CE_ENSURE(pkg_data != ResourceData::NOT_FOUND); |
| 263 | |
| 264 | if (rr.online_order > pkg_data.online_sequence_num) { |
| 265 | // Cannot process this resource yet; we need to wait for all its requirements to be |
| 266 | // put online() first. Put the request back into the loaded queue to try again |
| 267 | // later. |
| 268 | _resource_loader->_loaded.push(rr); |
| 269 | } else { |
| 270 | ++pkg_data.online_sequence_num; |
| 271 | |
| 272 | if (!rr.is_spurious()) { |
| 273 | // If this is a non-spurious request, add it to the resource map. |
| 274 | resource_manager_internal::add_resource(*this |
| 275 | , rr.package_name |
| 276 | , rr.type |
| 277 | , rr.name |
| 278 | , rr.allocator |
| 279 | , rr.data |
| 280 | ); |
| 281 | } |
| 282 | } |
| 283 | } |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | void ResourceManager::register_type(StringId64 type, u32 version, LoadFunction load, UnloadFunction unload, OnlineFunction online, OfflineFunction offline) |
| 288 | { |
no test coverage detected