|
#region Copyright (c) 2012 Roman Atachiants
/*************************************************************************
*
* Copyright (C) 2012 Roman Atachiants
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*************************************************************************/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
namespace ObjectPool
{
/// <summary>
/// Defines a contract for an object pool.
/// </summary>
public interface IRecycler
{
/// <summary>
/// Acquires an instance of a recyclable object
/// </summary>
/// <returns></returns>
IRecyclable Acquire();
/// <summary>
/// Releases an instance of a recyclable object back to the pool.
/// </summary>
/// <param name="instance">The instance of IRecyclable to release.</param>
void Release(IRecyclable instance);
/// <summary>
/// Gets the overall number of elements managed by this pool.
/// </summary>
int Count { get; }
/// <summary>
/// Gets the number of available elements currently contained in the pool.
/// </summary>
int AvailableCount {get;}
/// <summary>
/// Gets the number of elements currently in use and not available in this pool.
/// </summary>
int InUseCount {get;}
}
/// <summary>
/// Defines a contract for an object pool.
/// </summary>
public interface IRecycler<T> : IRecycler
where T : class, IRecyclable
{
/// <summary>
/// Acquires an instance of a recyclable object
/// </summary>
/// <returns></returns>
new T Acquire();
/// <summary>
/// Releases an instance of a recyclable object back to the pool.
/// </summary>
/// <param name="instance">The instance of IRecyclable to release.</param>
void Release(T instance);
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.