Beispiel #1
0
 /// <inheritdoc />
 public virtual void ReturnObject(TPooledObject objectToRelease)
 {
     if (UsedObjectStore.Contains(objectToRelease))
     {
         UsedObjectStore.Remove(objectToRelease);
         UnusedObjectStore.Add(objectToRelease);
     }
 }
Beispiel #2
0
        /// <inheritdoc />
        public virtual void EnsureCapacity(int requestedCapacity)
        {
            while (UnusedObjectStore.Count < requestedCapacity)
            {
                if (UnusedObjectStore.Count + UsedObjectStore.Count == MaximumObjects)
                {
                    return;
                }

                TPooledObject newPooledObject = ObjectFactory.Create();
                UnusedObjectStore.Add(newPooledObject);
            }
        }