How can I limit Q promise concurrency?

前端 未结 4 1285
时光取名叫无心
时光取名叫无心 2020-12-09 19:31

How do I write a method that limits Q promise concurrency?

For instance, I have a method spawnProcess. It returns a Q promise.
I want no more than 5

4条回答
  •  遥遥无期
    2020-12-09 19:58

    The Deferred promise implementation has gate function which works exactly that way:

    spawnProcess = deferred.gate(spawnProcess, 5);    
    

提交回复
热议问题