What is the main thread doing when calling runtime.block_on? #6831
-
I am new to rust and tokio, and trying to rewrite a grpc server as a learning experience. I wish to gain a better understanding into how tokio manages its threads and what each thread is doing. I am running on Windows in this case.
When pausing the application, I see 2 threads that are executing rust code.
So my questions are:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Beta Was this translation helpful? Give feedback.
block_on
will only execute the single future you passed to it. No other tasks execute on that thread.tokio::spawn
task rather thanblock_on
so that it can run within the general pool, rather than being pinned to theblock_on
thread.block_on
call. The current-thread runtime does not execute tasks at all unless there is a call toblock_on
.