I posted this to Reddit and the real-time chat over the weekend, but in case anyone missed it I figured it would be worth posting it here as well as I've seen some questions about async floating around the forum lately. The idea is to update the series with an article on threading and a bit about communication, and possibly more topics. But for now you can enjoy the async installment: https://peterme.net/multitasking-in-nim.html
I'm wondering does nim have the facility like Promise.all() in javascript which can trigger multiple await in parallel and improve the performance of multiple async execution? For example, I have A request which takes 4 sec to finish, B request 5 sec, I want to have them running in parallel so I can get the result no more than 5 sec? My understanding is that if I write two await statement I have to wait for 9 sec to finish the async jobs?
As I mention in the article async only works if you have IO bound tasks. But assuming that your tasks are IO bound you can await multiple executions with andor allfrom the `asyncfutures`module (which is automatically imported from asyncdispatch). If your tasks are CPU bound then you simply can't use async to speed up your execution, as the CPU will still have to do all the work. For that you need multithreading, which will be the topic of the next article in the series.