3 ms·
the problem is that if you introduce async, your could should preferably async all the way to the bottom. of course you can trick yourself by using thread pools
by merb 5y ago
the problem is that if you introduce async, your could should preferably async all the way to the bottom.
of course you can trick yourself by using thread pools and move long running functions to them, but not everybody knows that.
of course sync functions have the same problem (not the same problem, but it's the same concept, just in the other way), except that most frameworks just deal with it at the very front, so developers do not need to deal with it.
- pornel 5y agoThe whole point is that use of async doesn't need to be infectious. You may want to make everything async for elegance and consistency, but it's not a requirement strong enough to cause problems. If you have a library that is sync-only, it's fine. If you have a large project and can't be bothered to rewrite everything to be async, it's fine. "Not everybody knows (how to do) that" is a weak argument, because it's a relatively straightforward thing to learn: if it can block, wrap it in `spawn_blocking()`.
- ibraheemdev 5y ago> of course you can trick yourself by using thread pools and move long running functions to them How is that tricking yourself? Blocking code exists, and you will almost always run into it one way or the other.