How is reactor shared across threads when running tokio multithreaded?

Just the title. I am currently building a very basic async runtime to learn the internals and am using a thread local for storing and accessing the reactor. If there are multiple threads, how is shared access provided to the individual workers to a single reactor? Or are there multiple reactors?

One of the threads will block on the reactor by calling epoll_wait with a timeout equal to the smallest timer. Other threads go to sleep using std::thread::park().

How to determine which thread does what? Basically when a thread goes to sleep, it checks if there is already one sleeping on epoll, and if there isn't then it will do it.

Is the reactor stored within a lazy static with the usage of Arc<Mutex<…>> for example? Also are the handles for the threads also stored as a lazy static for other threads to unpark them?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.