I would like to have a program that executes one million asynchronous tasks over a long period of time. I want to manage the concurrency dynamically, but we can imagine simpler version with concurrency 20.
I made a system that is using tokio::task::spawn
for each of those asynchronous tasks. tokio::task::spawn
requires a Future
with the 'static
lifetime. If I somehow make my futures static, how would that influence my program long term memory consumption? Would there be some memory accumulation of the futures that were already awaited? Or only thing that would actually accumulate is the thing that is making that future 'static
?
Could I pass into each future somewhere dummy static data like &str
to make the future static but hold no memory after it is awaited? I'm missing some core understanding here.