com.faunos.util.cc
Class SchedulingService

java.lang.Object
  extended by com.faunos.util.cc.SchedulingService
Direct Known Subclasses:
Environment

public class SchedulingService
extends Object

An execution environment using the Scheduler idiom.

Author:
Babak Farhang
See Also:
Scheduler

Constructor Summary
SchedulingService()
           
 
Method Summary
 void addScheduler(Scheduler scheduler)
           
 int getMaxThreadPoolSize()
           
protected  int getThreadPoolSize(int schedulerCount)
          Returns the number of threads the pool will maintain given the specified number of schedulers.
 void setMaxThreadPoolSize(int size)
           
 void shutdown()
           
 void signalWorkAvailable(Scheduler scheduler)
           
protected  int waitPeriodMillis(int inProgress, int newlyScheduled)
          Returns the period the scheduling thread waits before attempting to schedule more work.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchedulingService

public SchedulingService()
Method Detail

getMaxThreadPoolSize

public int getMaxThreadPoolSize()

setMaxThreadPoolSize

public void setMaxThreadPoolSize(int size)

addScheduler

public void addScheduler(Scheduler scheduler)

signalWorkAvailable

public void signalWorkAvailable(Scheduler scheduler)

shutdown

public void shutdown()

waitPeriodMillis

protected int waitPeriodMillis(int inProgress,
                               int newlyScheduled)
Returns the period the scheduling thread waits before attempting to schedule more work. This implementation returns 1 second if nothing was scheduled, and 5 seconds, o.w.; the inProgress parameter is ignored by the base class.

Parameters:
inProgress - the number of in progress tasks
newlyScheduled - the number of newly scheduled tasks
Returns:
the number of milliseconds to wait

getThreadPoolSize

protected int getThreadPoolSize(int schedulerCount)
Returns the number of threads the pool will maintain given the specified number of schedulers.

(The actual number of threads will be bounded by the max thread pool size property.)

Returns:
the base implementation just returns schedulerCount.


SourceForge.net Logo