Investigate an alternative approach, and then wholesale replace the existing resource loading system.
The alternative will have these constraints and goals:
* immutable authoritive source seems to be impossible without large efforts in architecture as when f.e. a buffer is loaded we obviously need to be able to write to it if it's used for those purposes.
Notes:
protect disk based assets:
The current approach selects the "last loaded" to be the authoritive source of what is the disk based assets (for the find method), but allows load to be called N times and get a fresh version as if just loaded from disk
complex interaction:
As the system has been implemented using coroutines, you can simply use co_await in the construct method and await for you relevant signal to fire, or to switch to other threads.
reference tracked/manual resource management:
All resources are always tracked by default. This isn't toggleable for now (this is to satisfy the safe resource destruction requirement). However, you can control when resources get destroyed if it's safe to do so (i.e. the last references are held by the cache, and the caller). The try_destroy method will verify if it's safe, and will destroy the resource within the given scope.
Alternatively, the unsafe_destroy will forcibly destroy the resource. This functionality is hidden behind the RESOURCE_ALLOW_UNSAFE define.
consider renaming construct to co_construct /s
Investigate an alternative approach, and then wholesale replace the existing resource loading system.
The alternative will have these constraints and goals:
* immutable authoritive source seems to be impossible without large efforts in architecture as when f.e. a buffer is loaded we obviously need to be able to write to it if it's used for those purposes.
Notes:
protect disk based assets:
The current approach selects the "last loaded" to be the authoritive source of what is the disk based assets (for the
findmethod), but allows load to be called N times and get a fresh version as if just loaded from diskcomplex interaction:
As the system has been implemented using coroutines, you can simply use
co_awaitin theconstructmethod and await for you relevant signal to fire, or to switch to other threads.reference tracked/manual resource management:
All resources are always tracked by default. This isn't toggleable for now (this is to satisfy the safe resource destruction requirement). However, you can control when resources get destroyed if it's safe to do so (i.e. the last references are held by the cache, and the caller). The
try_destroymethod will verify if it's safe, and will destroy the resource within the given scope.Alternatively, the
unsafe_destroywill forcibly destroy the resource. This functionality is hidden behind theRESOURCE_ALLOW_UNSAFEdefine.consider renaming
constructtoco_construct/s