When to use different block_on functions?
#303
-
|
In
Of the three, What I don't understand, is when to use The documentation here is fairly sparse (the core difference being "processing I/O events when idle" or not), but that doesn't give me a good intuition on when each The executor docs use |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Really there is no difference. If you care about benchmarks, If you can't decide it can't hurt to just use |
Beta Was this translation helpful? Give feedback.
Really there is no difference.
smol::block_onsets up the thread to run the I/O reactor whilesmol::future::block_ondoesn't. However, the I/O reactor can run on its own thread even ifsmol::block_onisn't running. So functionally there is no difference.If you care about benchmarks,
smol::future::block_onis slightly faster to run if you are blocking on a lot of little futures. So in general I usesmol::block_onfor long-running futures andsmol::future::block_onif I have to block on a tiny one.If you can't decide it can't hurt to just use
smol::block_on.