ariba.util.core
Class Pool

java.lang.Object
  extended by ariba.util.core.Pool
All Implemented Interfaces:
LockHandlerConditions

public class Pool
extends java.lang.Object
implements LockHandlerConditions

Generic resource pooling mechanism


Nested Class Summary
static class Pool.PoolChangeReason
          Used with poolChange method to indicate the reason the pool was changed.
 
Field Summary
 int allocationMiss
           
 int allocationSum
           
 int allocationWaitTimeSeconds
           
 
Constructor Summary
Pool(java.lang.String name)
           
 
Method Summary
 void add(Linkable linkable)
          Add a new resource to the pool.
 Linkable allocate()
          Allocate a resource for our use.
 Linkable allocate(java.util.Comparator comparator)
           
 Linkable allocateIfAny()
          Allocate a resource for our use if one is available, otherwise return null.
 Linkable allocateIfAvailable(Linkable obj)
          Allocate a resource for our use if one is available, otherwise return null.
 boolean doWithLock(LockHandlerContext result)
          return false to indicate continuation context is allocated by caller to LockHandler.doWithLock and can be used to pass, by reference, any number of result data etc.
 int freeCount()
           
 int inUseCount()
           
 void release(Linkable linkable)
          Release an allocated resource for others to use.
 void remove(Linkable linkable)
          Remove a resource from the pool.
 int size()
           
 long timeoutIntervalMillis()
          the time, in milliseconds, to wait Called WITH LOCK
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

allocationWaitTimeSeconds

public int allocationWaitTimeSeconds

allocationSum

public int allocationSum

allocationMiss

public int allocationMiss
Constructor Detail

Pool

public Pool(java.lang.String name)
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

inUseCount

public int inUseCount()

freeCount

public int freeCount()

size

public int size()

add

public void add(Linkable linkable)
Add a new resource to the pool.


remove

public void remove(Linkable linkable)
Remove a resource from the pool. Note, you can only remove something from the list if you currently have it allocated.


allocate

public Linkable allocate()
Allocate a resource for our use. Write diagnotics periodically when the lock is held for longer than the timeout.


doWithLock

public boolean doWithLock(LockHandlerContext result)
Description copied from interface: LockHandlerConditions
return false to indicate continuation context is allocated by caller to LockHandler.doWithLock and can be used to pass, by reference, any number of result data etc. Called WITH LOCK

Specified by:
doWithLock in interface LockHandlerConditions

timeoutIntervalMillis

public long timeoutIntervalMillis()
Description copied from interface: LockHandlerConditions
the time, in milliseconds, to wait Called WITH LOCK

Specified by:
timeoutIntervalMillis in interface LockHandlerConditions

allocateIfAny

public Linkable allocateIfAny()
Allocate a resource for our use if one is available, otherwise return null.


allocateIfAvailable

public Linkable allocateIfAvailable(Linkable obj)
Allocate a resource for our use if one is available, otherwise return null.


release

public void release(Linkable linkable)
Release an allocated resource for others to use.


allocate

public Linkable allocate(java.util.Comparator comparator)


AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.