title: Keep X requests running in parallel until N requests completed
body: <p>I'm having trouble finding an appropriate construct for the given use case. </p>
  
  <p>I have a function that for the given input string generates a <code>Single&lt;String&gt;</code>. This <code>Single</code> is a combination of multiple tasks that are expected to take up to half a minute, but I think this is not relevant to the question. </p>
  
  <p>The behavior I am trying to achieve is having 5 of these tasks active in parallel with the goal of completing N tasks. Since the tasks are expensive not only time-wise, no excess tasks should be started that would be discarded later. It is not important to somehow merge the results of these tasks, I simply persist each result in <code>onSuccess</code>. </p>
  
  <p>So basically my plan is to have a counter variable that starts at 0. Then, in a loop, generate 5 <code>Single</code>, increasing the counter by 5. Subscribe to them, <code>onComplete</code> increase the counter and <code>onTerminate</code> if <code>counter</code> &lt; N, start another <code>Single</code>. </p>
  
  <p>In the end, however, I lack a good way to keep track of the recursively generated <code>Single</code> objects, but I need to wait until N are finished. </p>
  
  <p>Is there a construct available that would make this easy, or should I try to achieve this with counters or a list of <code>Disposable</code>? </p>