com.octo.android.robospice.priority
Class PriorityThreadPoolExecutor

java.lang.Object
  extended by java.util.concurrent.AbstractExecutorService
      extended by java.util.concurrent.ThreadPoolExecutor
          extended by com.octo.android.robospice.priority.PausableThreadPoolExecutor
              extended by com.octo.android.robospice.priority.PriorityThreadPoolExecutor
All Implemented Interfaces:
Executor, ExecutorService

public final class PriorityThreadPoolExecutor
extends PausableThreadPoolExecutor

A ThreadPoolExecutor with priority management, from SOF
There are some inherent limitations to this mechanism. For instance, the first runnable/callable passed to the executor doesn't go in the queue. Thus the priority mechanism will only apply when tasks are queued, and this happens when the number of current runners is exceeds the number of max thread in the pool size.

Author:
SNI

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
 
Constructor Summary
PriorityThreadPoolExecutor(int poolSize)
           
PriorityThreadPoolExecutor(int poolSize, int threadPriority)
           
PriorityThreadPoolExecutor(int corePoolSize, int maxPoolSize, int threadPriority)
           
 
Method Summary
static PriorityThreadPoolExecutor getPriorityExecutor(int nThreads)
           
static PriorityThreadPoolExecutor getPriorityExecutor(int nThreads, int threadPriority)
           
static PriorityThreadPoolExecutor getPriorityExecutor(int nCoreThreads, int maxPoolSize, int threadPriority)
           
protected
<T> RunnableFuture<T>
newTaskFor(Runnable runnable, T value)
           
 Future<?> submit(Runnable task)
           
 
Methods inherited from class com.octo.android.robospice.priority.PausableThreadPoolExecutor
pause, resume
 
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, terminated
 
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, submit, submit
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PriorityThreadPoolExecutor

public PriorityThreadPoolExecutor(int corePoolSize,
                                  int maxPoolSize,
                                  int threadPriority)

PriorityThreadPoolExecutor

public PriorityThreadPoolExecutor(int poolSize,
                                  int threadPriority)

PriorityThreadPoolExecutor

public PriorityThreadPoolExecutor(int poolSize)
Method Detail

getPriorityExecutor

public static PriorityThreadPoolExecutor getPriorityExecutor(int nCoreThreads,
                                                             int maxPoolSize,
                                                             int threadPriority)

getPriorityExecutor

public static PriorityThreadPoolExecutor getPriorityExecutor(int nThreads,
                                                             int threadPriority)

getPriorityExecutor

public static PriorityThreadPoolExecutor getPriorityExecutor(int nThreads)

newTaskFor

protected <T> RunnableFuture<T> newTaskFor(Runnable runnable,
                                           T value)
Overrides:
newTaskFor in class AbstractExecutorService

submit

public Future<?> submit(Runnable task)
Specified by:
submit in interface ExecutorService
Overrides:
submit in class AbstractExecutorService


Copyright © 2012-2014. All Rights Reserved.