Skip to content

Commit

Permalink
Fix pool shrinking with new allocations
Browse files Browse the repository at this point in the history
Make BAllocThread.reduceSizeByDeallocating() call refill on the disregardPile and the newAllocations.
Otherwise, the pool might not be able to deallocate objects allocated but unused prior to a new target size being set.
This is normally not a big deal for pools that have any sort of activity, but the `ThreadedPoolTest.decreasingSizeMustNotDeallocateTlrClaimedObjects` test could end up in an infinite loop, and break the build.
  • Loading branch information
chrisvest committed May 27, 2024
1 parent e807e69 commit 734c18b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/stormpot/BAllocThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ private void increaseSizeByAllocating() {
}

private void reduceSizeByDeallocating(BSlot<T> slot) {
if (slot == null || !didAnythingLastIteration) {
disregardPile.refill();
newAllocations.refill();
}
slot = slot == null ? live.poll() : slot;
if (slot != null) {
if (slot.isDead() || slot.live2dead()) {
Expand Down

0 comments on commit 734c18b

Please sign in to comment.