- make IPoolItem disposable and add use method, can be used with using now

master
Simon G 5 years ago
parent 7aa637deb3
commit 1ea6d259bc
  1. 10
      GBase/DataHandling/Pool/PoolItem.cs
  2. 8
      GBase/Interfaces/DataHandling/Pool/IPoolItem.cs

@ -14,6 +14,14 @@ namespace GBase.DataHandling.Pool
} }
public T Item { get; } public T Item { get; }
public bool InUse { get; set; } public bool InUse { get; private set; }
public T Use()
{
InUse = true;
return Item;
}
public void Dispose() => InUse = false;
} }
} }

@ -2,11 +2,15 @@
// Created: 2020-09-19 // Created: 2020-09-19
// Copyright(c) 2020 SimonG. All Rights Reserved. // Copyright(c) 2020 SimonG. All Rights Reserved.
using System;
namespace GBase.Interfaces.DataHandling.Pool namespace GBase.Interfaces.DataHandling.Pool
{ {
public interface IPoolItem<T> public interface IPoolItem<T> : IDisposable
{ {
T Item { get; } T Item { get; }
bool InUse { get; set; } bool InUse { get; }
T Use();
} }
} }
Loading…
Cancel
Save