Re:Lies we tell ourselves to keep using Golang
by paskozdilar on Friday April 29, 2022 @11:21AM
(#31206296)
If you could spare some time, would you please demonstrate an example?
[ Parent
| on HN ]
Re:Lies we tell ourselves to keep using Golang
by vbezhenar on Friday April 29, 2022 @12:07PM
(#31206999)
You can use Promise.race to wait for the first resolved promise.
Re:Lies we tell ourselves to keep using Golang
by moralestapia on Friday April 29, 2022 @11:31AM
(#31206450)
Abusing notation a bit,
var a = new Queue();
var b = new Queue();
a.read(() => some callback);
b.read(() => some callback);
And code continues here without blocking.
To be honest, I think you could do the same in any (slightly) modern language.
Re:Lies we tell ourselves to keep using Golang
by paskozdilar on Friday April 29, 2022 @02:45PM
(#31209135)
Is the read() call running a task in the background? In that case, that's equivalent to launching two threads. For n queues, you'd need n tasks, and they'd hang in the background in case they never get a result and take up memory.