net.wimpi.text
Class ResourcePool

java.lang.Object
  |
  +--net.wimpi.text.ResourcePool

public class ResourcePool
extends java.lang.Object

Class that implements a pool for ProcessingResource instances.
The factory method is used for creating pools of the given resource and size, using the resource's factory method to create the requested amount of instances.

Version:
0.2 19/11/2002
Author:
Dieter Wimberger
See Also:
ProcessingResource.createResource()

Method Summary
 void clear()
          Removes all ProcessingResource references from this pool.
static ResourcePool createResourcePool(int size, ProcessingResource resource)
          Creates a ResourcePool with the given size, containing the given ProcessingResource instances.
 int getCeiling()
          Returns the ceiling (in terms of size) of this pool.
protected  void initPool()
          Initializes a pool of ProcessingResource instances.
 ProcessingResource leaseResource()
          Returns a leased ProcessingResource instance from this pool.
 void releaseResource(ProcessingResource resource)
          Releases a formerly leased ProcessingResource, returning it into this pool.
 void resize(int size)
          Resizes the pool.
 int size()
          Returns the size of this pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

leaseResource

public ProcessingResource leaseResource()
Returns a leased ProcessingResource instance from this pool.
Returns:
the leased ProcessingResource from this pool.

releaseResource

public void releaseResource(ProcessingResource resource)
Releases a formerly leased ProcessingResource, returning it into this pool.
Parameters:
resource - the formerly leased ProcessingResource to be released.

getCeiling

public int getCeiling()
Returns the ceiling (in terms of size) of this pool.
Returns:
the ceiling size of this pool as int.

size

public int size()
Returns the size of this pool.
Returns:
the actual size of this pool as int.

resize

public void resize(int size)
Resizes the pool.
Parameters:
size - the new size as int.

clear

public void clear()
Removes all ProcessingResource references from this pool. Note that it will do so gracefully, waiting for leased ProcessingResources.

initPool

protected void initPool()
Initializes a pool of ProcessingResource instances.

createResourcePool

public static ResourcePool createResourcePool(int size,
                                              ProcessingResource resource)
Creates a ResourcePool with the given size, containing the given ProcessingResource instances.
Parameters:
size - the size as int.
resource - the ProcessingResource to be pooled.


Copyright 2001,2002 Dieter Wimberger. All Rights Reserved.