When (ab)using the asset registry in a highly parallel fashion we will run into deadlocks, where all threadpool threads are synchronously waiting on some async asset task. This can be observed in the validation-command branch when run over all assets.
Synchronous asset loading (as was the norm before asset registry) was added to not massively complicate the existing game code and should be kept. Zanzarah is a single-threaded game, so is zzio, even though we might speed up asset loading in isolation of the other code. Here is a possible solution:
Add a new AssetHandle.GetAsync method
Check and prevent any synchronous Task.Wait calls on non-main threads
Maybe replace the Monitor locks with SemaphoreSlim to enable better asynchronous access to asset objects.
When (ab)using the asset registry in a highly parallel fashion we will run into deadlocks, where all threadpool threads are synchronously waiting on some async asset task. This can be observed in the validation-command branch when run over all assets.
Synchronous asset loading (as was the norm before asset registry) was added to not massively complicate the existing game code and should be kept. Zanzarah is a single-threaded game, so is zzio, even though we might speed up asset loading in isolation of the other code. Here is a possible solution:
AssetHandle.GetAsync
methodTask.Wait
calls on non-main threadsMonitor
locks withSemaphoreSlim
to enable better asynchronous access to asset objects.