3 ms·
Does anyone realistically shut down the Tokio runtime once it's been started? It wouldn't be a problem if the runtime is immortal once created; the runtime refe
by Filligree 2y ago
Does anyone realistically shut down the Tokio runtime once it's been started? It wouldn't be a problem if the runtime is immortal once created; the runtime reference becomes more of a token demonstrating that, yes, this is running under Tokio.
Though I don't think this is such a huge problem. Yes, it's a runtime crash that could potentially be eliminated at compile-time, but realistically that will only happen once during development, and it will be an easy fix.
- kelnos 2y agoIf I'm writing an async program (that is, with an async main()), then no, I'll never be shutting my runtime down. But if I already have a non-async program, but need to use an async library, then yes, I'll probably spin up the runtime before using the library, and shut it down after I'm done using it. Unless of course I expect to be using that library for the full run-time of my program, in which case it'll exist for the duration.
- Joker_vD 2y ago> I'll probably spin up the runtime before using the library, and shut it down after I'm done using it. Hopefully the library did not leave any background tasks running that you can't ask it to stop :) Raymond Chen has a lot of enlightening horror stories about multi-threaded COM (and multi-threaded programming in general) on his blog that are applicable not only to Windows, but in general context as well.