Package com.biglybt.core.util
Class ThreadPool
- java.lang.Object
-
- com.biglybt.core.util.ThreadPool
-
public class ThreadPool extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
ThreadPool.threadPoolWorker
-
Field Summary
Fields Modifier and Type Field Description private java.util.List
busy
private static boolean
busy_pool_timer_set
(package private) static java.util.List
busy_pools
private int
current_permits
private static boolean
debug_thread_pool
private static boolean
debug_thread_pool_log_on
private long
execution_limit
private boolean
log_cpu
private static boolean
LOG_WARNINGS
private java.lang.String
name
private static boolean
NAME_THREADS
private boolean
queue_when_full
private int
target_permits
private Average
task_average
private java.util.List<AERunnable>
task_queue
private long
task_total
private long
task_total_last
private int
thread_name_index
private int
thread_priority
private AESemaphore
thread_sem
(package private) static java.lang.ThreadLocal
tls
private static int
WARN_TIME
private boolean
warn_when_full
-
Constructor Summary
Constructors Constructor Description ThreadPool(java.lang.String _name, int _max_size)
ThreadPool(java.lang.String _name, int _max_size, boolean _queue_when_full)
-
Method Summary
-
-
-
Field Detail
-
NAME_THREADS
private static final boolean NAME_THREADS
-
LOG_WARNINGS
private static final boolean LOG_WARNINGS
- See Also:
- Constant Field Values
-
WARN_TIME
private static final int WARN_TIME
- See Also:
- Constant Field Values
-
busy_pools
static final java.util.List busy_pools
-
busy_pool_timer_set
private static boolean busy_pool_timer_set
-
debug_thread_pool
private static boolean debug_thread_pool
-
debug_thread_pool_log_on
private static boolean debug_thread_pool_log_on
-
tls
static final java.lang.ThreadLocal tls
-
name
private final java.lang.String name
-
thread_name_index
private int thread_name_index
-
execution_limit
private long execution_limit
-
busy
private final java.util.List busy
-
queue_when_full
private final boolean queue_when_full
-
task_queue
private final java.util.List<AERunnable> task_queue
-
thread_sem
private final AESemaphore thread_sem
-
target_permits
private int target_permits
-
current_permits
private int current_permits
-
thread_priority
private int thread_priority
-
warn_when_full
private boolean warn_when_full
-
task_total
private long task_total
-
task_total_last
private long task_total_last
-
task_average
private final Average task_average
-
log_cpu
private boolean log_cpu
-
-
Method Detail
-
checkAllTimeouts
protected static void checkAllTimeouts()
-
generateEvidence
private void generateEvidence(IndentWriter writer)
-
setWarnWhenFull
public void setWarnWhenFull()
-
setLogCPU
public void setLogCPU()
-
getMaxThreads
public int getMaxThreads()
-
setThreadPriority
public void setThreadPriority(int _priority)
-
setExecutionLimit
public void setExecutionLimit(long millis)
-
run
public ThreadPool.threadPoolWorker run(AERunnable runnable)
-
run
public ThreadPool.threadPoolWorker run(AERunnable runnable, boolean high_priority, boolean manualRelease)
- Parameters:
runnable
-high_priority
- inserts at front if tasks queueing
-
runIt
protected void runIt(AERunnable runnable)
-
checkWarning
protected void checkWarning()
-
getQueuedTasks
public AERunnable[] getQueuedTasks()
-
getOldestQueuedTask
public AERunnable getOldestQueuedTask()
-
getQueueSize
public int getQueueSize()
-
isQueued
public boolean isQueued(AERunnable task)
-
getRunningTasks
public AERunnable[] getRunningTasks()
-
getRunningCount
public int getRunningCount()
-
isFull
public boolean isFull()
-
setMaxThreads
public void setMaxThreads(int max)
-
checkTimeouts
protected void checkTimeouts()
-
getName
public java.lang.String getName()
-
releaseManual
void releaseManual(ThreadPoolTask toRelease)
-
registerThreadAsChild
public void registerThreadAsChild(ThreadPool.threadPoolWorker parent)
-
deregisterThreadAsChild
public void deregisterThreadAsChild(ThreadPool.threadPoolWorker parent)
-
-