From 1ea6d259bc381b34804e0c51f6b178d6d57afce9 Mon Sep 17 00:00:00 2001 From: Simon G Date: Fri, 13 Nov 2020 13:51:25 +0100 Subject: [PATCH] - make IPoolItem disposable and add use method, can be used with using now --- GBase/DataHandling/Pool/PoolItem.cs | 10 +++++++++- GBase/Interfaces/DataHandling/Pool/IPoolItem.cs | 8 ++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/GBase/DataHandling/Pool/PoolItem.cs b/GBase/DataHandling/Pool/PoolItem.cs index 90fd4e9..1b62010 100644 --- a/GBase/DataHandling/Pool/PoolItem.cs +++ b/GBase/DataHandling/Pool/PoolItem.cs @@ -14,6 +14,14 @@ namespace GBase.DataHandling.Pool } 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; } } \ No newline at end of file diff --git a/GBase/Interfaces/DataHandling/Pool/IPoolItem.cs b/GBase/Interfaces/DataHandling/Pool/IPoolItem.cs index 8cdb3d9..6833696 100644 --- a/GBase/Interfaces/DataHandling/Pool/IPoolItem.cs +++ b/GBase/Interfaces/DataHandling/Pool/IPoolItem.cs @@ -2,11 +2,15 @@ // Created: 2020-09-19 // Copyright(c) 2020 SimonG. All Rights Reserved. +using System; + namespace GBase.Interfaces.DataHandling.Pool { - public interface IPoolItem + public interface IPoolItem : IDisposable { T Item { get; } - bool InUse { get; set; } + bool InUse { get; } + + T Use(); } } \ No newline at end of file