3 ms·
If you could spare some time, would you please demonstrate an example?
by paskozdilar 4y ago
If you could spare some time, would you please demonstrate an example?
- vbezhenar 4y agoYou can use Promise.race to wait for the first resolved promise.
- moralestapia 4y agoAbusing 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.
- paskozdilar 4y agoIs 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.