Execute async code every milliseconds then create a future

Hello,

I use rust since two years and I love it. I have not already wrote async/await code. For m'y next project i would like use rust again.

This project is a little daemon playing non player character of my game.

I have to execute for each of them, a function at regular interval. I found this. I think to create a Vector containing a future for each of my non player character which execute this interval function.

But I wonder a question. If I have to add a non player character, how to add it's own future to other pool of execution ?

Thanks !

You can just call the spawn method of your executor, usually tokio::spawn, giving the method your future.

1 Like

Thanks ! I will use that :slight_smile: