Hi everyone! I have a normal old gameloop and I would like to load files to memory without blocking the whole game, essentially loading in the background. How would I go about this? The file is guaranteed to not be needed instantly, but its gotta load at some point! I wrote pseudocode for the desired behaviour below, any help will be much appreciated!
fn main() {
// Initialisation blah blah
// Main game loop
loop {
// Obvs we wont allways have something loading in the bg
if let Some(queued_file_op) = file_queued_option {
if queued_file_op.is_done() {
some_struct_somewhere.push(queued_file_op.data());
file_queued_option = None;
} else {
// Draw a loading bar or something idk
}
}
run_the_game_without_being_blocked_by_file_io();
}
}