view Implab/ObjectPoolWrapper.cs @ 83:397fe8db0806 v2

fixed object pool
author cin
date Mon, 29 Sep 2014 15:49:15 +0400
parents 0363407ee75c
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
    }
}