keypool
keypool copied to clipboard
Implement fairness
commons-pool2 functionality
In commons-pool2, fairness determines whether requests are serviced in FIFO or LIFO order. The default is LIFO.
Current behavior
keypool only supports FIFO.
Analysis
This is a configuration for good reason. A nice visualization of the tradeoffs is in this queueing article.
The semaphore that lurks within Keypool effectively imposes FIFO ordering. Fixing this would effectively require Keypool reimplement some semaphore-like semantics.
Notably, in the feature comparison, keypool stands alone with its FIFO default.
Workarounds
None
One can also imagine a priority queue here, but that would require an enhanced borrow interface that accepted a priority as an argument.