MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / Update

Method Update

modules/engine/runtime/src/resource/resource_request.cpp:247–506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

245}
246
247void SResourceRequestImpl::Update()
248{
249 SMutexLock lock(updateMutex.mMutex);
250 if (requireLoading != isLoading)
251 {
252 if (requireLoading)
253 UpdateLoad(requestInstall);
254 else
255 UpdateUnload();
256 }
257 auto resourceRegistry = system->GetRegistry();
258 auto ioService = system->GetRAMService();
259 SKR_LOG_BACKTRACE(u8"Current reosurce loading phase: %d!", (int32_t)currentPhase);
260 switch (currentPhase)
261 {
262 case SKR_LOADING_PHASE_REQUEST_RESOURCE: {
263 auto fopened = resourceRegistry->RequestResourceFile(this);
264 if (fopened)
265 currentPhase = SKR_LOADING_PHASE_IO;
266 else
267 {
268 currentPhase = SKR_LOADING_PHASE_FINISHED;
269 // TODO: Do something with this rude code
270 resourceRecord->SetStatus(SKR_LOADING_STATUS_ERROR);
271 }
272 }
273 break;
274 case SKR_LOADING_PHASE_WAITFOR_RESOURCE_REQUEST:
275 break;
276 case SKR_LOADING_PHASE_IO:
277 resourceRecord->SetStatus(SKR_LOADING_STATUS_LOADING);
278 if (factory->AsyncIO())
279 {
280 {
281 auto rq = ioService->open_request();
282 rq->set_vfs(vfs);
283 rq->set_path(resourceUrl.u8_str());
284 rq->add_block({}); // read all
285 SKR_ASSERT(dataFuture.status == 0);
286 dataBlob = ioService->request(rq, &dataFuture);
287 }
288#ifdef SKR_RESOURCE_DEV_MODE
289 if (!artifactsUrl.is_empty())
290 {
291 auto rq = ioService->open_request();
292 rq->set_vfs(vfs);
293 rq->set_path(artifactsUrl.u8_str());
294 rq->add_block({}); // read all
295 SKR_ASSERT(artifactsFuture.status == 0);
296 artifactsBlob = ioService->request(rq, &artifactsFuture);
297 }
298#endif
299 currentPhase = SKR_LOADING_PHASE_WAITFOR_IO;
300 }
301 else
302 {
303 {
304 auto file = skr_vfs_fopen(vfs, (const char8_t*)resourceUrl.c_str(), SKR_FM_READ_BINARY, SKR_FILE_CREATION_OPEN_EXISTING);

Callers

nothing calls this directly

Calls 15

skr_vfs_fopenFunction · 0.85
skr_vfs_fcloseFunction · 0.85
skr_vfs_fsizeFunction · 0.85
skr_vfs_freadFunction · 0.85
GetRegistryMethod · 0.80
GetRAMServiceMethod · 0.80
RequestResourceFileMethod · 0.80
SetStatusMethod · 0.80
open_requestMethod · 0.80
get_serializedMethod · 0.80
CancelRequestFileMethod · 0.80

Tested by

no test coverage detected