Mercurial > pub > ImplabNet
diff Implab/ObjectPoolWrapper.cs @ 82:0363407ee75c v2
added object pool
author | cin |
---|---|
date | Mon, 29 Sep 2014 05:04:32 +0400 |
parents | |
children | 34bb2f32634d |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab/ObjectPoolWrapper.cs Mon Sep 29 05:04:32 2014 +0400 @@ -0,0 +1,24 @@ +using System; + +namespace Implab { + public struct ObjectPoolWrapper<T> : IDisposable { + readonly T m_value; + readonly ObjectPool<T> m_pool; + + internal ObjectPoolWrapper(T value, ObjectPool<T> pool) { + m_value = value; + m_pool = pool; + } + + public T Value { + get { return m_value; } + } + + #region IDisposable implementation + public void Dispose() { + m_pool.Release(m_value); + } + #endregion + } +} +