Tokio + Winit? #2953
-
Hi, I'm trying to get winit to work with tokio, but the problem is that winit has it's own event loop which needs to run on the main thread. So the question is; how can I make these two work together? I have a couple of ideas how to do this; one would be to run the tokio runtime on a separate thread and just let winit have the main thread. I was thinking I could create a channel to communicate messages from winit to my tokio code. But is it possible to run the tokio runtime in a separate thread? Or are there other strategies that would work better? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You should run the Tokio runtime on a separate thread. You can do this by creating a new |
Beta Was this translation helpful? Give feedback.
You should run the Tokio runtime on a separate thread. You can do this by creating a new
tokio::runtime::Runtime
object and callingspawn
on it to create the root future.