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_on
sets up the thread to run the I/O reactor whilesmol::future::block_on
doesn't. However, the I/O reactor can run on its own thread even ifsmol::block_on
isn't running. So functionally there is no difference.If you care about benchmarks,
smol::future::block_on
is slightly faster to run if you are blocking on a lot of little futures. So in general I usesmol::block_on
for long-running futures andsmol::future::block_on
if I have to block on a tiny one.If you can't decide it can't hurt to just use
smol::block_on
.