Exemplo n.º 1
0
 public void MarkReturning()
 {
     lock (syncLock)
     {
         state = PooledObjectState.Returning;
     }
 }
Exemplo n.º 2
0
 public void Invalidate()
 {
     lock (this.syncRoot)
     {
         state = PooledObjectState.INVALID;
     }
 }
Exemplo n.º 3
0
 public void MarkAbandoned()
 {
     lock (syncLock)
     {
         state = PooledObjectState.Abandoned;
     }
 }
Exemplo n.º 4
0
 public void Invalidate()
 {
     lock (syncLock)
     {
         state = PooledObjectState.Invalid;
     }
 }
Exemplo n.º 5
0
        public bool StartEvictionTest()
        {
            if (state == PooledObjectState.Idle)
            {
                state = PooledObjectState.Eviction;
                return(true);
            }

            return(false);
        }
Exemplo n.º 6
0
        public bool StartEvictionTest()
        {
            lock (this.syncRoot)
            {
                if (state == PooledObjectState.IDLE)
                {
                    state = PooledObjectState.MAINTAIN_EVICTION;
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 7
0
        public bool Deallocate()
        {
            if (state == PooledObjectState.Allocated ||
                state == PooledObjectState.Returning)
            {
                state          = PooledObjectState.Idle;
                lastReturnTime = DateTime.Now.CurrentTimeMillis();
                borrowedBy     = null;
                return(true);
            }

            return(false);
        }
Exemplo n.º 8
0
        public bool Deallocate()
        {
            lock (this.syncRoot)
            {
                if (state == PooledObjectState.ALLOCATED)
                {
                    state            = PooledObjectState.IDLE;
                    lastReturnedTime = DateTime.Now;
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 9
0
 public void Release()
 {
     if (_poolState == PooledObjectState.Acquired)
     {
         _poolState = PooledObjectState.Releasing;
         RaiseOnReleased();
         ReleaseInternal();
         ReturnToPool();
     }
     else
     {
         throw new ObjectPoolException("Can only release Acquired objects");
     }
 }
Exemplo n.º 10
0
 public bool EndEvictionTest(Deque <IPooledObject <T> > idleQueue)
 {
     if (state == PooledObjectState.Eviction)
     {
         state = PooledObjectState.Idle;
         return(true);
     }
     else if (state == PooledObjectState.EvictionReturnToHead)
     {
         state = PooledObjectState.Idle;
         //if (!idleQueue.offerFirst(this)) {
         //    // TODO - Should never happen
     }
     return(false);
 }
Exemplo n.º 11
0
        public bool EndEvictionTest(LinkedBlockingDeque <PooledObject <T> > idleQueue)
        {
            lock (this.syncRoot)
            {
                if (state == PooledObjectState.MAINTAIN_EVICTION)
                {
                    state = PooledObjectState.IDLE;
                    return(true);
                }
                else if (state == PooledObjectState.MAINTAIN_EVICTION_RETURN_TO_HEAD)
                {
                    state = PooledObjectState.IDLE;
                    idleQueue.OfferFirst(this);
                }
            }

            return(false);
        }
Exemplo n.º 12
0
        public bool Allocate()
        {
            lock (this.syncRoot)
            {
                if (state == PooledObjectState.IDLE)
                {
                    state            = PooledObjectState.ALLOCATED;
                    lastBorrowedTime = DateTime.Now;
                    return(true);
                }
                else if (state == PooledObjectState.MAINTAIN_EVICTION)
                {
                    state = PooledObjectState.MAINTAIN_EVICTION_RETURN_TO_HEAD;
                    return(false);
                }
            }

            return(false);
        }
Exemplo n.º 13
0
 public bool Allocate()
 {
     if (state == PooledObjectState.Idle)
     {
         state          = PooledObjectState.Allocated;
         lastBorrowTime = DateTime.Now.CurrentTimeMillis();
         lastUseTime    = lastBorrowTime;
         borrowedCount++;
         if (logAbandoned)
         {
             borrowedBy = new AbandonedObjectCreatedException();
         }
         return(true);
     }
     else if (state == PooledObjectState.Eviction)
     {
         // TODO Allocate anyway and ignore eviction test
         state = PooledObjectState.EvictionReturnToHead;
         return(false);
     }
     // TODO if validating and testOnBorrow == true then pre-allocate for
     // performance
     return(false);
 }