Skip to content

Commit

Permalink
tidy up the race around size and seen live items
Browse files Browse the repository at this point in the history
  • Loading branch information
msillence authored and chrisvest committed May 31, 2024
1 parent 6a4f7cc commit 508526e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
8 changes: 5 additions & 3 deletions src/main/java/stormpot/BAllocThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -396,12 +396,14 @@ int allocatedSize() {
}

int inUse() {
int inUse = size - live.size(); // slots not in live are in thread locals?
int inUse = 0;
int liveSize = 0;
for (BSlot<T> slot: live) {
liveSize++;
if (slot.isClaimedOrThreadLocal()) {
inUse++;
}
}
return inUse;
}
return size - liveSize + inUse;
}
}
6 changes: 4 additions & 2 deletions src/main/java/stormpot/DirectAllocationController.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,14 @@ public int allocatedSize() {
}

int inUse() {

Check notice

Code scanning / CodeQL

Missing Override annotation Note

This method overrides
AllocationController.inUse
; it is advisable to add an Override annotation.
int inUse = size - live.size();
int inUse = 0;
int liveSize = 0;
for (BSlot<T> slot: live) {
liveSize++;
if (slot.isClaimedOrThreadLocal()) {
inUse++;
}
}
return inUse;
return size - liveSize + inUse;
}
}
8 changes: 5 additions & 3 deletions src/main/java/stormpot/InlineAllocationController.java
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,14 @@ public int allocatedSize() {
}

int inUse() {

Check notice

Code scanning / CodeQL

Missing Override annotation Note

This method overrides
AllocationController.inUse
; it is advisable to add an Override annotation.
int inUse = size - live.size();
int inUse = 0;
int liveSize = 0;
for (BSlot<T> slot: live) {
liveSize++;
if (slot.isClaimedOrThreadLocal()) {
inUse++;
}
}
return inUse;
}
return size - liveSize + inUse;
}
}

0 comments on commit 508526e

Please sign in to comment.