コード例 #1
0
 /// <summary>
 /// Puts a PooledBitReader back into the pool
 /// </summary>
 /// <param name="reader">The reader to put in the pool</param>
 public static void PutBackInPool(PooledBitReader reader)
 {
     if (readers.Count < 64)
     {
         readers.Enqueue(reader);
     }
     else
     {
         Debug.Log("BitReaderPool already has 64 queued. Throwing to GC. Did you forget to dispose?");
     }
 }
コード例 #2
0
 /// <summary>
 /// Puts a PooledBitReader back into the pool
 /// </summary>
 /// <param name="reader">The reader to put in the pool</param>
 public static void PutBackInPool(PooledBitReader reader)
 {
     if (readers.Count < 64)
     {
         readers.Enqueue(reader);
     }
     else if (LogHelper.CurrentLogLevel <= LogLevel.Developer)
     {
         LogHelper.LogInfo("BitReaderPool already has 64 queued. Throwing to GC. Did you forget to dispose?");
     }
 }
コード例 #3
0
        /// <summary>
        /// Retrieves a PooledBitReader
        /// </summary>
        /// <param name="stream">The stream the reader should read from</param>
        /// <returns>A PooledBitReader</returns>
        public static PooledBitReader GetReader(Stream stream)
        {
            if (readers.Count == 0)
            {
                if (createdReaders == 254)
                {
                    Debug.LogWarning("255 readers have been created. Did you forget to dispose?");
                }
                else if (createdReaders < 255)
                {
                    createdReaders++;
                }

                return(new PooledBitReader(stream));
            }

            PooledBitReader reader = readers.Dequeue();

            reader.SetStream(stream);

            return(reader);
        }