org.jwarp.util.recycle
Class AdaptiveController
java.lang.Object
|
+--org.jwarp.util.recycle.AdaptiveController
- All Implemented Interfaces:
- IController
- public class AdaptiveController
- extends java.lang.Object
- implements IController
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.
- Author:
- Anatole Tresch
| Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AdaptiveController
public AdaptiveController()
objectAdded
public void objectAdded()
- Signal an object recycle.
- Specified by:
objectAdded in interface IController
objectRemoved
public void objectRemoved()
- Signal an object request.
- Specified by:
objectRemoved in interface IController
canAddObject
public boolean canAddObject(IRecyclable object)
- Evaluates the room for the recyclable object
- Specified by:
canAddObject in interface IController