Maven (famous) to Programmer [email protected] • 10 months agoSTOP DOING ASYNCimagemessage-square60arrow-up1722arrow-down137
arrow-up1685arrow-down1imageSTOP DOING ASYNCMaven (famous) to Programmer [email protected] • 10 months agomessage-square60
minus-square@[email protected]linkfedilink1•10 months agoIf you need to get multiple pieces of data for one request Async is great, but why would you work on different requests in the same thread? Why slow down one request because the other needs a bunch of computation?
minus-square@[email protected]linkfedilink3•10 months agoYou aren’t slowing down anything. If you didn’t use async that thread would be blocked. You’d need a thread per request even though they are sat doing nothing while waiting for responses. Instead when you hit an await that thread is freed for other work and when the wait is over the rest of the code is scheduled to run.
If you need to get multiple pieces of data for one request Async is great, but why would you work on different requests in the same thread? Why slow down one request because the other needs a bunch of computation?
You aren’t slowing down anything. If you didn’t use async that thread would be blocked.
You’d need a thread per request even though they are sat doing nothing while waiting for responses.
Instead when you hit an await that thread is freed for other work and when the wait is over the rest of the code is scheduled to run.