Implementing an async queue in 23 lines of code

Recently we had an interesting task at work. The user makes a selection of items and clicks a button. Then for every selected item we have to make a request to our API. The thing is that the user may click as many items as he/she wants. In order to speed up the process up we decided to handle four requests in parallel and once some of them is finished we pull the next one. If you ask why exactly four requests in parallel read this paper.

Link: http://krasimirtsonev.com/blog/article/implementing-an-async-queue-in-23-lines-of-code