MCPcopy Create free account
hub / github.com/crownengine/crown / complete_requests

Method complete_requests

src/resource/resource_manager.cpp:244–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

242}
243
244void 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
287void ResourceManager::register_type(StringId64 type, u32 version, LoadFunction load, UnloadFunction unload, OnlineFunction online, OfflineFunction offline)
288{

Callers 4

loadMethod · 0.80
flushMethod · 0.80
frameMethod · 0.80
main_loopMethod · 0.80

Calls 5

add_resourceFunction · 0.85
getFunction · 0.85
is_spuriousMethod · 0.80
popMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected