Exemple #1
0
			public void Free()
			{
				if ( m_Enumerator != null )
				{
					m_InstancePool.Enqueue( this );

					m_Enumerator.Free();
					m_Enumerator = null;

					--m_Depth;
				}
			}
Exemple #2
0
			public static PooledEnumerable Instantiate( IPooledEnumerator etor )
			{
				++m_Depth;

				if ( m_Depth >= 5 )
					Console.WriteLine( "Warning: Make sure to call .Free() on pooled enumerables." );

				PooledEnumerable e;

				if ( m_InstancePool.Count > 0 )
				{
					e = m_InstancePool.Dequeue();
					e.m_Enumerator = etor;
				}
				else
				{
					e = new PooledEnumerable( etor );
				}

				etor.Enumerable = e;

				return e;
			}
Exemple #3
0
            public void Free()
            {
                if ( m_Enumerator != null )
                {
                    m_InstancePool.Enqueue( this );

                    m_Enumerator.Free();
                    m_Enumerator = null;

                    --m_Depth;
                }
            }
Exemple #4
0
            public static PooledEnumerable Instantiate( IPooledEnumerator etor )
            {
                ++m_Depth;

                if ( m_Depth >= 5 )
                    log.WarnFormat("Make sure to call .Free() on pooled enumerables.");

                PooledEnumerable e;

                if ( m_InstancePool.Count > 0 )
                {
                    e = (PooledEnumerable)m_InstancePool.Dequeue();
                    e.m_Enumerator = etor;
                }
                else
                {
                    e = new PooledEnumerable( etor );
                }

                etor.Enumerable = e;

                return e;
            }
Exemple #5
0
 private PooledEnumerable( IPooledEnumerator etor )
 {
     m_Enumerator = etor;
 }
Exemple #6
0
			private PooledEnumerable( IPooledEnumerator etor )
			{
				m_Enumerator = etor;
			}
Exemple #7
0
			public void Free()
			{
				if (m_Enumerator != null)
				{
					// reset
					this.Status = PooledEnumerable.status.normal;

					m_InstancePool.Enqueue(this);

					m_Enumerator.Free();
					m_Enumerator = null;

					--m_Depth;
				}
			}
Exemple #8
0
			public static PooledEnumerable Instantiate(IPooledEnumerator etor)
			{
				++m_Depth;                          // track current depth
				if (m_Depth > m_HighWaterMark)      // track max depth
					m_HighWaterMark = m_Depth;

				if (m_Depth >= 5)
					Console.WriteLine("PooledEnumerable: Depth = {0}, High Water Mark = {1}", m_Depth, m_HighWaterMark);

				PooledEnumerable e;

				if (m_InstancePool.Count > 0)
				{
					e = (PooledEnumerable)m_InstancePool.Dequeue();
					e.m_Enumerator = etor;

					if (e != null && e.Status != PooledEnumerable.status.normal && e.Status != PooledEnumerable.status.derived_moveNext)
					{	// always happens. Back to the drawing board.
						// string message = String.Format("PooledEnumerable.Instantiate() called after the derived class was: {0}", e.Status.ToString());
						// Console.WriteLine(message);
					}

					if (etor == null)
					{   // TEST
						string message = String.Format("PooledEnumerable.Instantiate() etor starting out null");
						Console.WriteLine(message);
					}

				}
				else
				{
					e = new PooledEnumerable(etor);
				}

				etor.Enumerable = e;

				// reset
				e.Status = PooledEnumerable.status.normal;

				return e;
			}