tc39 / proposal-concurrency-control

interfaces and data structures for concurrency control and integration into async iterator helpers
30 stars 0 forks source link

acquiring has to be cancellable #10

Open michaelficarra opened 1 week ago

michaelficarra commented 1 week ago

We thought that this may be the case, but I was really confronted with the need when implementing the summing combinator (any) in https://github.com/tc39/proposal-concurrency-control/pull/9. The only way we can "race" Governors is to try to acquire all of them and then race the promises. Unfortunately, once we acquire the first one, we can't cancel the other attempts. Instead, we just have to queue up a release once they resolve. This wouldn't be so bad if we were only considering simple counting Governors. But since we want Governors to also be able to implement time-based rate limiting, acquiring and immediately releasing a token is not equivalent to aborting an acquisition attempt (or just never attempting to acquire). So I don't see any way around depending on some kind of cancellation.