Skip to content

What is the best practice to loading content in the background? #228

Answered by 17cupsofcoffee
Im-Oab asked this question in Q&A
Discussion options

You must be logged in to vote

I think the ideal solution is to have assets load on a seperate thread - you can then use something like a channel or an atomic to communicate back to the main thread what the progress is.

The important thing to consider is that Context can't be accessed unless you're on the main thread - so for types like Texture which need to access Context, you'll need to pass the loaded file back across to the main thread to create your final asset (e.g. via Texture::from_file_data).

I'll try to write up an example of what this could look like, it's something I've been meaning to do for a while!

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Im-Oab
Comment options

@17cupsofcoffee
Comment options

Answer selected by Im-Oab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants