Merged
Conversation
Feat: New ObjectPool and PooledObjectHandle added. Feat: Additional new IPoolable interface added and new ObjectPoolPoolable class added. (both a still in review and might be removed)
…apper for extensions
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the object pooling system by replacing the interface-based implementation with a simpler, generic, thread-safe approach. The new design uses ConcurrentBag<T> for thread safety and provides a disposable handle pattern for automatic resource management.
Key changes:
- Replaces the old
IPool,IPoolable,Pool, andPoolHandlerclasses with a new genericObjectPool<T>andPooledObjectHandle<T>implementation - Introduces thread-safe pooling using
ConcurrentBag<T>instead of manual list management - Adds a disposable handle pattern that automatically returns instances to the pool when disposed
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| ShapeEngine/Pool/ObjectPool.cs | New thread-safe generic object pool implementation using ConcurrentBag |
| ShapeEngine/Pool/PooledObjectHandle.cs | New disposable handle for automatic pool return via IDisposable pattern |
| ShapeEngine/Pool/Pool.cs | Removed legacy Pool implementation |
| ShapeEngine/Pool/PoolHandler.cs | Removed legacy PoolHandler for managing multiple pools |
| ShapeEngine/Pool/IPool.cs | Removed legacy IPool interface |
| ShapeEngine/Pool/IPoolable.cs | Removed legacy IPoolable interface |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ObjectPool.cs Refactor: Improved disposing system in PooledObjectHandle.cs Feat: Added IsDisposed and IsValid to PooledObjectHandle.cs
Contributor
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have removed the old system completely and replaced it with a simplified, thread-safe, and generic version of
ObjectPool<T>.The new system can be used manually or with an
PooledObjectHandle<T>.The manual way consist of getting an instance withGet()and returning the instance once finished withReturn(). The second option is to get a handle for a pool object that automatically returns the contained instance when it is disposed.The new system is using a
ConcurrentBag<T>internally.