com.caucho.env.thread2
Class AbstractThreadLauncher2

java.lang.Object
  extended by com.caucho.env.thread2.AbstractTaskWorker2
      extended by com.caucho.env.thread2.AbstractThreadLauncher2
All Implemented Interfaces:
TaskWorker, java.io.Closeable, java.lang.Runnable
Direct Known Subclasses:
AbstractThreadLauncher

@Module
public abstract class AbstractThreadLauncher2
extends AbstractTaskWorker2


Constructor Summary
protected AbstractThreadLauncher2()
           
protected AbstractThreadLauncher2(java.lang.ClassLoader loader)
           
 
Method Summary
 void close()
           
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.
 boolean isIdleLow()
           
 boolean isIdleOverflow()
          Start the idle if the child idle is less than idle max.
protected  boolean isIdleTooLow(int startingCount)
           
 boolean isThreadHigh()
           
 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 onChildThreadLaunchBegin()
          Callback from the launched thread's run().
 void onChildThreadLaunchEnd()
          Callback from the launched thread's run().
 void onChildThreadResumeBegin()
          Start housekeeping for a child thread managed by the launcher's housekeeping, but not spawned by the launcher itself, e.g.
 void onChildThreadResumeEnd()
          End housekeeping for a child thread managed by the launcher's housekeeping, but not spawned by the launcher itself, e.g.
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.thread2.AbstractTaskWorker2
getClassLoader, getCurrentTimeActual, getThreadName, isClosed, isPermanent, isTaskActive, onThreadComplete, onThreadStart, run, setWorkerIdleTimeout, startWorkerThread, toString, unpark, wake
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractThreadLauncher2

protected AbstractThreadLauncher2()

AbstractThreadLauncher2

protected AbstractThreadLauncher2(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()

close

public void close()
Specified by:
close in interface java.io.Closeable
Overrides:
close in class AbstractTaskWorker2

isThreadMax

public boolean isThreadMax()

isThreadHigh

public boolean isThreadHigh()

onChildThreadLaunchBegin

public void onChildThreadLaunchBegin()
Callback from the launched thread's run(). Must _not_ be called by any other method, including other spawning.


onChildThreadLaunchEnd

public void onChildThreadLaunchEnd()
Callback from the launched thread's run(). Must _not_ be called by any other method, including other spawning.


onChildThreadResumeBegin

public void onChildThreadResumeBegin()
Start housekeeping for a child thread managed by the launcher's housekeeping, but not spawned by the launcher itself, e.g. comet, websocket, keepalive.


onChildThreadResumeEnd

public void onChildThreadResumeEnd()
End housekeeping for a child thread managed by the launcher's housekeeping, but not spawned by the launcher itself, e.g. comet, websocket, keepalive.


isIdleExpire

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


isIdleLow

public final boolean isIdleLow()

isIdleOverflow

public boolean isIdleOverflow()
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)

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 AbstractTaskWorker2