title: serialize concurent operations using resources
body: <p>I have a list of operations. Each operation uses one resource. Some operations use the same resource.
  For example op1 uses the same resource as op3.
  symbolic code:</p>
  
  <pre><code>operations=[op1,op2,op3,op4,op5]
  for (let i=0;i&lt;operations.length;i++) {
    perform(operations[i])
  }
  </code></pre>
  
  <p>fails because op1 and op3 uses the same resource. 
  So another aproach:</p>
  
  <pre><code>operations=[op1,op2,op3,op4,op5]
  for (let i=0;i&lt;operations.length;i++) {
    await perform(operations[i])
  }
  </code></pre>
  
  <p>does not fail, but op2 unnecessary waits for o1 to be finished even though they don't use the same resource.</p>
  
  <p>other approach:</p>
  
  <pre><code>operations=[op1,op2,op3,op4,op5]
  for (let i=0;i&lt;operations.length;i++) {
    await operations[i].usedResource.isAvailable;
    perform(operations[i])
  }
  </code></pre>
  
  <p>OK, op1 runs, op2 runs, op3 waits for resource blocked by op1,... but op4 and op5 waits as well for no reason.</p>
  
  <p>Any ideas?</p>