Package org.eclipse.jetty.util.thread
Class ScheduledExecutorScheduler
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.thread.ScheduledExecutorScheduler
@ManagedObject
public class ScheduledExecutorScheduler
extends AbstractLifeCycle
implements Scheduler, Dumpable
Implementation of
Scheduler based on JDK's ScheduledThreadPoolExecutor.
While use of ScheduledThreadPoolExecutor creates futures that will not be used,
it has the advantage of allowing to set a property to remove cancelled tasks from its
queue even if the task did not fire, which provides a huge benefit in the performance
of garbage collection in young generation.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopExceptionNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.ListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Scheduler
Scheduler.Task -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionScheduledExecutorScheduler(String name, boolean daemon) ScheduledExecutorScheduler(String name, boolean daemon, int threads) ScheduledExecutorScheduler(String name, boolean daemon, ClassLoader classLoader) ScheduledExecutorScheduler(String name, boolean daemon, ClassLoader classLoader, ThreadGroup threadGroup) ScheduledExecutorScheduler(String name, boolean daemon, ClassLoader classLoader, ThreadGroup threadGroup, int threads) ScheduledExecutorScheduler(ScheduledExecutorService scheduledExecutorService) -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoStart()Method to override to start the lifecycleprotected voiddoStop()Method to override to stop the lifecycledump()voiddump(Appendable out, String indent) Dump this object (and children) into an Appendable using the provided indent after any new lines.getName()intbooleanisDaemon()Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addEventListener, getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeEventListener, setEventListeners, start, stop, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addEventListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeEventListener, start, stop
-
Constructor Details
-
ScheduledExecutorScheduler
public ScheduledExecutorScheduler() -
ScheduledExecutorScheduler
-
ScheduledExecutorScheduler
-
ScheduledExecutorScheduler
-
ScheduledExecutorScheduler
public ScheduledExecutorScheduler(String name, boolean daemon, ClassLoader classLoader, ThreadGroup threadGroup) -
ScheduledExecutorScheduler
public ScheduledExecutorScheduler(@Name("name") String name, @Name("daemon") boolean daemon, @Name("classLoader") ClassLoader classLoader, @Name("threadGroup") ThreadGroup threadGroup, @Name("threads") int threads) - Parameters:
name- The name of the scheduler threads or null for automatic namedaemon- True if scheduler threads should be daemonclassLoader- The classloader to run the threads with or null to use the current thread context classloaderthreadGroup- The threadgroup to use or null for no thread groupthreads- The number of threads to pass to the coreScheduledExecutorServiceor -1 for a heuristic determined number of threads.
-
ScheduledExecutorScheduler
- Parameters:
scheduledExecutorService- the coreScheduledExecutorServiceto be used
-
-
Method Details
-
doStart
Description copied from class:AbstractLifeCycleMethod to override to start the lifecycle- Overrides:
doStartin classAbstractLifeCycle- Throws:
AbstractLifeCycle.StopException- If thrown, the lifecycle will immediately be stopped.Exception- If there was a problem starting. Will cause a transition to FAILED state
-
doStop
Description copied from class:AbstractLifeCycleMethod to override to stop the lifecycle- Overrides:
doStopin classAbstractLifeCycle- Throws:
Exception- If there was a problem stopping. Will cause a transition to FAILED state
-
schedule
-
dump
-
dump
Description copied from interface:DumpableDump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.- Specified by:
dumpin interfaceDumpable- Parameters:
out- The appendable to dump toindent- The indent to apply after any new lines.- Throws:
IOException- if unable to write to Appendable
-
getName
-
isDaemon
-
getThreads
-