678
STOP DOING ASYNC (lemmy.world)
submitted 9 months ago by Maven@lemmy.world to c/programmerhumor@lemmy.ml
you are viewing a single comment's thread
view the rest of the comments
[-] Bene7rddso@feddit.de 1 points 9 months ago

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?

[-] Lmaydev@programming.dev 3 points 9 months ago

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.

this post was submitted on 28 Jan 2024
678 points (94.8% liked)

Programmer Humor

32481 readers
239 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS