kiwi.util
Class TimerPool

java.lang.Object
  |
  +--kiwi.util.ResourcePool
        |
        +--kiwi.util.TimerPool

public class TimerPool
extends ResourcePool

A concrete implementation of ResourcePool for managing a pool of IntervalTimers.

Author:
Mark Lindner, PING Software Group

Fields inherited from class kiwi.util.ResourcePool
availableList, reservedList, size
 
Constructor Summary
TimerPool(int size)
          Construct a new TimerPool of the specified size.
 
Method Summary
protected  Resource constructResource()
          Construct a new IntervalTimer.
 void releaseTimer(IntervalTimer timer)
          Release a timer back into the pool.
 IntervalTimer reserveTimer()
          Reserve a timer from the pool.
 
Methods inherited from class kiwi.util.ResourcePool
getAvailableResourceCount, getTotalResourceCount, getUsedResourceCount, releaseResource, reserveResource
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Constructor Detail

TimerPool

public TimerPool(int size)
Construct a new TimerPool of the specified size.
Parameters:
size - The number of IntervalTimers to preallocate.
Method Detail

constructResource

protected Resource constructResource()
Construct a new IntervalTimer.
Overrides:
constructResource in class ResourcePool
Returns:
The new IntervalTimer.

reserveTimer

public IntervalTimer reserveTimer()
Reserve a timer from the pool. If all timers are currently in use, the method blocks until one becomes available.
Returns:
An IntervalTimer instance.

releaseTimer

public void releaseTimer(IntervalTimer timer)
Release a timer back into the pool.
Parameters:
timer - The timer to release.