Package net.toddm.comm
Class DefaultPriorityManagmentProvider
- java.lang.Object
-
- net.toddm.comm.DefaultPriorityManagmentProvider
-
- All Implemented Interfaces:
PriorityManagementProvider
public class DefaultPriorityManagmentProvider extends Object implements PriorityManagementProvider
A simple implementation ofPriorityManagementProviderthat guards against starvation with simple timestamps based priority promotion.- Author:
- Todd S. Murchison
-
-
Constructor Summary
Constructors Constructor Description DefaultPriorityManagmentProvider(net.toddm.cache.LoggingProvider loggingProvider)Returns an instance ofDefaultPriorityManagmentProvider.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Comparator<Priority>getPriorityComparator()Returns aComparatorthat will be used to control priority order and thus effect the order in which work is attempted.voidpromotePriority(Priority priority)Decides if the given instance ofPriorityshould be adjusted and makes the adjustment if it should.
Note:CommManagerwill call this method each time it is deciding if work should begin, implement accordingly.
-
-
-
Constructor Detail
-
DefaultPriorityManagmentProvider
public DefaultPriorityManagmentProvider(net.toddm.cache.LoggingProvider loggingProvider)
Returns an instance ofDefaultPriorityManagmentProvider.- Parameters:
loggingProvider- OPTIONAL If NULL no logging callbacks are made otherwise the provided implementation will get log messages.
-
-
Method Detail
-
promotePriority
public void promotePriority(Priority priority)
Decides if the given instance ofPriorityshould be adjusted and makes the adjustment if it should.
Note:CommManagerwill call this method each time it is deciding if work should begin, implement accordingly.This implementation does simple priority promotion based on age to help alleviate queue starvation.
- Specified by:
promotePriorityin interfacePriorityManagementProvider
-
getPriorityComparator
public Comparator<Priority> getPriorityComparator()
Returns aComparatorthat will be used to control priority order and thus effect the order in which work is attempted. Note:CommManagerwill call this method each time it is deciding if work should begin, implement accordingly.This implementation sorts on priority values and then on creation timestamp for equal priorities.
- Specified by:
getPriorityComparatorin interfacePriorityManagementProvider
-
-