com.caucho.env.thread
Class AbstractThreadLauncher

java.lang.Object
  extended by com.caucho.env.thread.AbstractTaskWorker
      extended by com.caucho.env.thread.AbstractThreadLauncher
All Implemented Interfaces:
java.lang.Runnable

@Module
public abstract class AbstractThreadLauncher
extends AbstractTaskWorker


Constructor Summary
protected AbstractThreadLauncher()
           
protected AbstractThreadLauncher(java.lang.ClassLoader loader)
           
 
Method Summary
 boolean childIdleBegin()
          Start the idle if the child idle is less than idle max.
 void destroy()
           
protected  boolean doStart()
          Checks if the launcher should start another thread.
 long getCreateCountTotal()
           
 int getIdleCount()
           
 int getIdleMax()
          Gets the maximum number of idle threads.
 int getIdleMin()
          Gets the minimum number of idle threads.
 long getIdleTimeout()
          Returns the idle timeout.
 int getStartingCount()
           
 int getThreadCount()
           
 int getThreadMax()
          Gets the maximum number of threads.
protected  boolean isEnable()
           
 boolean isIdleExpire()
          Returns true if the thread should expire instead of going to the idle state.
protected  boolean isIdleTooLow(int startingCount)
           
protected  boolean isPermanent()
           
 boolean isThreadMax()
           
protected abstract  void launchChildThread(int id)
           
 void onChildIdleBegin()
          Called by the thread before going into the idle state.
 void onChildIdleEnd()
          Called by the thread after exiting the idle state.
 void onChildThreadBegin()
          Thread activity management
 void onChildThreadEnd()
          Thread activity management
 void onChildThreadResume()
          Resume a child, i.e.
protected  void onThreadMax()
           
protected  void onThrottle(java.lang.String msg)
           
 long runTask()
           
 void setIdleMax(int max)
          Sets the maximum number of idle threads.
 void setIdleMin(int min)
          Sets the minimum number of idle threads.
 void setIdleTimeout(long timeout)
          Sets the idle timeout
 void setThreadMax(int max)
          Sets the maximum number of threads.
 void setThrottleLimit(int limit)
          Sets the throttle limit.
 void setThrottlePeriod(long period)
          Sets the throttle period.
 void setThrottleSleepTime(long period)
          Sets the throttle sleep time.
 void start()
           
protected  void update()
           
protected  void updateIdleExpireTime(long now)
          updates the thread idle expire time.
protected  void updateThrottle()
          Throttle the thread creation, so only 100 threads/sec (default) can be created.
 
Methods inherited from class com.caucho.env.thread.AbstractTaskWorker
getCurrentTimeActual, getThreadName, isClosed, isTaskActive, onThreadComplete, onThreadStart, run, setLoopCount, setWorkerIdleTimeout, startWorkerThread, toString, wake
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractThreadLauncher

protected AbstractThreadLauncher()

AbstractThreadLauncher

protected AbstractThreadLauncher(java.lang.ClassLoader loader)
Method Detail

launchChildThread

protected abstract void launchChildThread(int id)

setThreadMax

public void setThreadMax(int max)
Sets the maximum number of threads.


getThreadMax

public int getThreadMax()
Gets the maximum number of threads.


setIdleMin

public void setIdleMin(int min)
Sets the minimum number of idle threads.


getIdleMin

public int getIdleMin()
Gets the minimum number of idle threads.


setIdleMax

public void setIdleMax(int max)
Sets the maximum number of idle threads.


getIdleMax

public int getIdleMax()
Gets the maximum number of idle threads.


setIdleTimeout

public void setIdleTimeout(long timeout)
Sets the idle timeout


getIdleTimeout

public long getIdleTimeout()
Returns the idle timeout.


isEnable

protected boolean isEnable()

setThrottlePeriod

public void setThrottlePeriod(long period)
Sets the throttle period.


setThrottleLimit

public void setThrottleLimit(int limit)
Sets the throttle limit.


setThrottleSleepTime

public void setThrottleSleepTime(long period)
Sets the throttle sleep time.


start

public void start()

destroy

public void destroy()
Overrides:
destroy in class AbstractTaskWorker

isThreadMax

public boolean isThreadMax()

onChildThreadBegin

public void onChildThreadBegin()
Thread activity management


onChildThreadResume

public void onChildThreadResume()
Resume a child, i.e. start an active thread from an external source.


onChildThreadEnd

public void onChildThreadEnd()
Thread activity management


isIdleExpire

public boolean isIdleExpire()
Returns true if the thread should expire instead of going to the idle state.


childIdleBegin

public boolean childIdleBegin()
Start the idle if the child idle is less than idle max.


onChildIdleBegin

public void onChildIdleBegin()
Called by the thread before going into the idle state.


onChildIdleEnd

public void onChildIdleEnd()
Called by the thread after exiting the idle state.


updateIdleExpireTime

protected void updateIdleExpireTime(long now)
updates the thread idle expire time.


doStart

protected boolean doStart()
Checks if the launcher should start another thread.


isIdleTooLow

protected boolean isIdleTooLow(int startingCount)

isPermanent

protected boolean isPermanent()
Overrides:
isPermanent in class AbstractTaskWorker

update

protected void update()

updateThrottle

protected void updateThrottle()
Throttle the thread creation, so only 100 threads/sec (default) can be created.


onThreadMax

protected void onThreadMax()

onThrottle

protected void onThrottle(java.lang.String msg)

getThreadCount

public int getThreadCount()

getIdleCount

public int getIdleCount()

getStartingCount

public int getStartingCount()

getCreateCountTotal

public long getCreateCountTotal()

runTask

public long runTask()
Specified by:
runTask in class AbstractTaskWorker