view 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 source

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
    }
}