hi, I was wondering how tokio task spawn actually sends the task to the executor if run. How does it connect to tokio::main exactly? Does the macro create syntax sugar around it? How is the executor in scope to receive the task?
If you're asking how tokio::task::spawn()
knows which executor is available, it's currently using thread-local storage. This is an implementation detail that is subject to change. But that's how it works today.
1 Like