Example #1
0
        public void GiveBackObject(int objHashCode)
        {
            if (this.hashTableStatus[objHashCode] == null)
            {
                return;
            }

            lock (this)
            {
                if (notUsePool)
                {
                    DistroyOneObject(objHashCode);
                    return;
                }


                this.hashTableStatus[objHashCode] = true;
                this.mIdleObjCount++;
                if (this.supportReset)
                {
                    IPooledObjSupporter supporter = (IPooledObjSupporter)this.hashTableObjs[objHashCode];
                    supporter.Reset();
                }

                if (this.CanShrink())
                {
                    this.Shrink();
                }
            }
        }
Example #2
0
    /// <summary>
    /// 将对象退回对象池
    /// </summary>
    /// <param name="objHashCode"></param>
    public void GiveBackObject(int objHashCode)
    {
        if (!m_hashTableStatus.ContainsKey(objHashCode) || m_hashTableStatus[objHashCode])
        {
            return;
        }

        ObjectPool pool = this;

        lock (pool)
        {
            if (m_hashTableStatus.ContainsKey(objHashCode) && !m_hashTableStatus[objHashCode])
            {
                m_hashTableStatus[objHashCode] = true;
                m_idleObjCount++;
                if (m_supportReset)
                {
                    try
                    {
                        IPooledObjSupporter supporter = (IPooledObjSupporter)m_hashTableObjs[objHashCode];
                        supporter.Reset();
                    }
                    catch (Exception ex)
                    {
                        DebugLogger.LogException(ex);
                    }
                }

                if (CanShrink())
                {
                    Shrink();
                }
            }
        }
    }
Example #3
0
        /// <summary>
        /// 将连接返回到对象池
        /// </summary>
        /// <param name="objHashCode"></param>
        public void GiveBackObject(int objHashCode)
        {
            if (this.hashTableStatus[objHashCode] == null)
            {
                return;
            }

            lock (this)
            {
                this.hashTableStatus[objHashCode] = true;
                if (this.supportReset)
                {
                    IPooledObjSupporter supporter = (IPooledObjSupporter)this.hashTableObjs[objHashCode];
                    supporter.Reset();
                }

                if (this.CanShrink())
                {
                    this.Shrink();
                }
            }
        }