Skip to content

Commit

Permalink
Expose ObjectBuffer, it's useful
Browse files Browse the repository at this point in the history
  • Loading branch information
Forest committed Feb 29, 2024
1 parent ff5f86a commit 86c36b0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Hazel/ObjectPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ namespace Hazel
public sealed class ObjectPool<T> where T : IRecyclable
{
private int numberCreated;
public int NumberCreated { get { return numberCreated; } }
public int NumberCreated => this.numberCreated;

public int NumberInUse { get { return this.inuse.Count; } }
public int NumberNotInUse { get { return this.pool.Count; } }
public int Size { get { return this.NumberInUse + this.NumberNotInUse; } }
public int NumberInUse => this.inuse.Count;
public int NumberNotInUse => this.pool.Count;
public int Size => this.NumberInUse + this.NumberNotInUse;

#if HAZEL_BAG
private readonly ConcurrentBag<T> pool = new ConcurrentBag<T>();
Expand All @@ -33,11 +33,11 @@ public sealed class ObjectPool<T> where T : IRecyclable
/// </summary>
/// <returns></returns>
private readonly Func<T> objectFactory;

/// <summary>
/// Internal constructor for our ObjectPool.
/// </summary>
internal ObjectPool(Func<T> objectFactory)
public ObjectPool(Func<T> objectFactory)
{
this.objectFactory = objectFactory;
}
Expand All @@ -46,7 +46,7 @@ internal ObjectPool(Func<T> objectFactory)
/// Returns a pooled object of type T, if none are available another is created.
/// </summary>
/// <returns>An instance of T.</returns>
internal T GetObject()
public T GetObject()
{
#if HAZEL_BAG
if (!pool.TryTake(out T item))
Expand Down Expand Up @@ -84,7 +84,7 @@ internal T GetObject()
/// Returns an object to the pool.
/// </summary>
/// <param name="item">The item to return.</param>
internal void PutObject(T item)
public void PutObject(T item)
{
if (inuse.TryRemove(item, out bool b))
{
Expand Down

0 comments on commit 86c36b0

Please sign in to comment.