Skip to content

Pool System Overhaul#108

Merged
SoloByte merged 5 commits intomainfrom
pool-overhaul
Nov 4, 2025
Merged

Pool System Overhaul#108
SoloByte merged 5 commits intomainfrom
pool-overhaul

Conversation

@SoloByte
Copy link
Collaborator

@SoloByte SoloByte commented Nov 4, 2025

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 with Get() and returning the instance once finished with Return(). 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.

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)
@SoloByte SoloByte added this to the 5.0 milestone Nov 4, 2025
@SoloByte SoloByte self-assigned this Nov 4, 2025
@SoloByte SoloByte added improvement Improvement of existing code. refactor labels Nov 4, 2025
@SoloByte SoloByte requested a review from Copilot November 4, 2025 15:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and PoolHandler classes with a new generic ObjectPool<T> and PooledObjectHandle<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
@SoloByte SoloByte requested a review from Copilot November 4, 2025 15:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@SoloByte SoloByte merged commit 490fecf into main Nov 4, 2025
7 checks passed
@SoloByte SoloByte deleted the pool-overhaul branch November 4, 2025 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement of existing code. refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants