Hi there, I have a lengthy function,
calc_triangles, and I need to run that every few nanoseconds, but I don’t want it to slow down the main thread, so I want to put it into a separate thread, hence my question.
As I understand it,
async is basically some magical rust sugar which runs the task defined within it on a thread set aside for these kinds of tasks. And, as far as I understand, I should use a library like
tokio to do this. Unfortunately I’m a bit lost as to how I should proceed, (I’ve never really understood
async even in C# where they say it’s so easy[?]) should I use
tokio::run_async as described in this blog post, or should I use
futures, which I don’t grasp either?
To explain the circumstances I’m attempting to use this for:
I have a complicated algorithm (Not really complicated, just computationally slow) that I use to render the snake in my
snake game, so I initially changed the algorithm to generate a cache of triangles every time I move the snake by one. But then I realized that moving the snake and calculating all the triangle is kind of dumb to do in one function call, and wanted to move it into a separate thread.
Sorry for the long question