Async: "function color bleed" problems and other issues... #64
atulkhare4096
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
A recent discussion with a co-worker got me thinking about how most of use
async. Most tutorials start off with a top-down approach, starting with the framework. Yes, it's absolutely wonderful to use sayaxumto create a REST API in minutes and the prototype works amazing well out of the box.Flash forward, and it's time to create a production solution, and now the "function color bleed" problem starts to creep in. Now,
asynctends to bleed its way through function signatures, starting from the top. Now, almost everything from the top to bottom requiresasync; that harmlesssleep(10);that we had used with abandon in other code bases can have all sort of unexpected side-effects. The mutexes that worked superbly, are now a potential booby trap if we did an.awaitwhen holding it. Even simple IO operations require a special mock library while testing to account forasync.Some of us reach for
spawn_blocking()in desperation but never question the basic design. These questions inspired me to create a new chapter on it: https://github.com/microsoft/RustTraining/blob/main/async-book/src/ch14-async-is-an-optimization-not-an-architecture.md.The above are my opinions, and it will be interesting to know what others think about it.
Beta Was this translation helpful? Give feedback.
All reactions