Dhaka o tokior sthanio shomoyer bebodhan 3 ghonta 17 minit 16 secend
tokior draghima 139° 45' purbo hole dhakar draghima koto?
Answers
Answered by
1
Answer:
First of all, indeed, for the multi-threaded scheduler, the number of OS threads is fixed to num_cpus.
Second, Tokio can swap the currently running task at every .await on a per-thread basis.
Third, the main function runs in its own task, which is spawned by the #[tokio::main] macro.
Therefore, for the first code block example, if there are 20 connected clients, there would be 21 tasks: one for the main macro + one for each of the 20 open TCP streams. For the second code block example, there would be 22 tasks because of the extra outer tokio::spawn but it's needless and doesn't add any concurrency.
Similar questions