Hi guys, I'm having an issue with loading async files from disk.
Let me give some context, code is in C++, I have 2 threads, main thread ( physic & render ) & IO thread ( in charge of loading files async ). Sometimes a request, while being loaded in the IO thread ( I'm using Windows API with ReadFileEx and SleepEx ), is removed from MainThread, causes the callback to fail. ( for example I moved too fast, and the loading request didn't finish, I was loading a texture, but the object is too far away from me, so I need to delete it )
I know one option is to not delete the request until read is done, but I don't like this approach because I don't like keeping objects with a pending request in a Update loop only checking if it was completed ( because I will need to implement that kinda Update check system for each class I create ).
Another idea is to create a list of loaded files, which will be called with the render fn from MainThread. The list contains all the files already read from the IO thread, if the request was deleted I just simply delete the memory, if the request is still alive, I do the callback.
The issue I saw in here is, what happen if I want to create a new thread, and I need to load any file from that new thread ( can be a task thread ), I would need to create a new list for that thread, and a function for it too.
Any ideas, lib or code that I can check about this?