Skip to content

Commit

Permalink
Fix ThreadLocalOverPerLockedStacksObjectPool<T>.PerCoreStack.FillFrom…
Browse files Browse the repository at this point in the history
…GlobalReserve() method throwing
  • Loading branch information
Enderlook committed Dec 6, 2021
1 parent 3058f61 commit e733ef5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ Initial release.
- Fix documentation
- Specify that `ObjectPool<T>.ApproximateCount()` must return `-1` if the operation is not supported.
- Specify that `ObjectPool<T>.Return(T obj)` must never fail silently if `obj` is `null`.
- Fix `DynamicObjectPool<T>` not auto-trimming.
- Fix `DynamicObjectPool<T>` not auto-trimming.
- Fix `ThreadLocalOverPerLockedStacksObjectPool<T>.Rent()` (implementation behind `ObjectPool<T>.Shared.Rent()`) throwing when getting elements from global reserve.
6 changes: 3 additions & 3 deletions Net Pools/src/ThreadLocalOverPerCoreLockedStacksObjectPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -586,13 +586,13 @@ public bool TryPush(T element)

ObjectWrapper<T?>[] items = array;

int length = Math.Min(MaxObjectsPerCore - count, globalCount);
int length = Math.Min(MaxObjectsPerCore - count_, globalCount);
int start = globalCount - length;
Array.Copy(globalReserve_, start, items, count, length);
Array.Copy(globalReserve_, start, items, count_, length);
Array.Clear(globalReserve_, start, length);

globalCount = start;
count += length;
count_ += length;

globalReserveCount = globalCount;
}
Expand Down

0 comments on commit e733ef5

Please sign in to comment.