org.apache.java.recycle
Class AdaptiveController
java.lang.Object
|
+--org.apache.java.recycle.AdaptiveController
- public class AdaptiveController
- extends java.lang.Object
- implements Controller
This controller creates a simple yet very effective negative feedback
that stabilizes the level of the container. It is based on a simple
idea but it proves to be very adaptive to any kind of load creating
the minimum level that, on average, the container needs to fully satisfy
its requests without consuming memory or being empty.
The control is based on the assumption that if the container is empty,
some new object will be created and will later on be recycled. Following
this assumption, when the container is empty, its optimum level is raised
to allow more objects to be stored when they will be recycled.
On the other end, when the container reaches its top level, it means
there are too many objects and the level is lowered.
There is room for objects to be recycled only when the level is lower
than the top one. Note that you don't need to define any parameter
to this controller since it will find the best top level based
on the history of the requests, optimizing memory use by itself.
- Version:
- $Revision: 1.3 $ $Date: 1999/06/24 00:50:48 $
Field Summary |
private int |
level
|
private int |
top
|
Method Summary |
void |
down()
Signal an object request. |
boolean |
isThereRoomFor(Recyclable object)
Evaluates the room for the recyclable object |
void |
up()
Signal an object recycle. |
Methods inherited from class java.lang.Object |
,
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
toString,
wait,
wait,
wait |
top
private int top
level
private int level
AdaptiveController
public AdaptiveController()
up
public void up()
- Signal an object recycle.
- Specified by:
- up in interface Controller
down
public void down()
- Signal an object request.
- Specified by:
- down in interface Controller
isThereRoomFor
public boolean isThereRoomFor(Recyclable object)
- Evaluates the room for the recyclable object
- Specified by:
- isThereRoomFor in interface Controller