public final class Threading extends Object
| Modifier and Type | Field and Description |
|---|---|
static Object |
CPU |
static boolean |
debugSynchronization |
static boolean |
traceBlockingTasks |
static boolean |
traceTaskDone |
static boolean |
traceTasksNotDone |
static boolean |
traceTaskTime |
static Object |
UNMANAGED |
| Modifier and Type | Method and Description |
|---|---|
static String |
debug()
Return a string containing multi-threading status for debugging purposes.
|
static TaskManager |
get(Object resource)
Get the task manager for the given resource.
|
static List<TaskManager> |
getAllTaskManagers()
Return all current TaskManager.
|
static BlockedThreadHandler |
getBlockedThreadHandler(Thread thread)
Return the object handling a case of a blocked thread for the given thread.
|
static TaskManager |
getCPUTaskManager() |
static DrivesTaskManager |
getDrivesTaskManager() |
static ThreadPoolTaskManager |
getUnmanagedTaskManager() |
static void |
init(ThreadFactory threadFactory,
Class<? extends TaskPriorityManager> taskPriorityManager,
int nbCPUThreads,
DrivesTaskManager.DrivesProvider drivesProvider,
int nbUnmanagedThreads)
Initialize multi-threading.
|
static boolean |
isInitialized() |
static String |
printStats()
Print statistics.
|
static void |
registerBlockedThreadHandler(BlockedThreadHandler handler,
Thread thread)
Rregister the given thread.
|
static void |
registerResource(Object resource,
TaskManager tm)
Register a resource.
|
static void |
unregisterBlockedThreadHandler(Thread thread)
Unregister the given thread.
|
static TaskManager |
unregisterResource(Object resource)
Unregister a resource.
|
static <TError extends Exception> |
waitFinished(Collection<? extends Task<?,TError>> tasks)
Wait for the given tasks to be done.
|
static void |
waitOneFinished(List<? extends Task<?,?>> tasks)
Wait for one of the given task to be done.
|
static <TError extends Exception> |
waitUnblockedWithError(Collection<AsyncSupplier<?,TError>> tasks)
Wait for the given tasks to finish, if one has an error this error is immediately thrown without waiting for other tasks.
|
public static boolean traceBlockingTasks
public static boolean traceTaskTime
public static boolean debugSynchronization
public static boolean traceTaskDone
public static boolean traceTasksNotDone
public static final Object CPU
public static final Object UNMANAGED
public static void init(ThreadFactory threadFactory, Class<? extends TaskPriorityManager> taskPriorityManager, int nbCPUThreads, DrivesTaskManager.DrivesProvider drivesProvider, int nbUnmanagedThreads)
LCCore.Environment instance on initialization.threadFactory - factory to use when creating threadstaskPriorityManager - the class to use to manage priority of tasksnbCPUThreads - number of threads to use for CPU tasks,
0 or negative value means the number of available processors returned by Runtime.availableProcessors()drivesProvider - provides physical drives and associated mount points.
If null, File.listRoots() is used and each returned root is considered as a physical drive.
This may be changed later on by calling DrivesTaskManager.setDrivesProvider(DrivesProvider).nbUnmanagedThreads - number of threads to use for unmanaged tasks.
If 0 or negative, maximum 100 threads will be used.public static boolean isInitialized()
public static TaskManager getCPUTaskManager()
public static DrivesTaskManager getDrivesTaskManager()
public static ThreadPoolTaskManager getUnmanagedTaskManager()
public static void registerResource(Object resource, TaskManager tm)
public static TaskManager unregisterResource(Object resource)
public static TaskManager get(Object resource)
public static List<TaskManager> getAllTaskManagers()
public static void registerBlockedThreadHandler(BlockedThreadHandler handler, Thread thread)
public static void unregisterBlockedThreadHandler(Thread thread)
public static BlockedThreadHandler getBlockedThreadHandler(Thread thread)
public static <TError extends Exception> void waitFinished(Collection<? extends Task<?,TError>> tasks) throws TError extends Exception, CancelException
TError extends ExceptionCancelExceptionpublic static <TError extends Exception> void waitUnblockedWithError(Collection<AsyncSupplier<?,TError>> tasks) throws TError extends Exception, CancelException
TError extends ExceptionCancelExceptionpublic static void waitOneFinished(List<? extends Task<?,?>> tasks)
public static String debug()
public static String printStats()
Copyright © 2019. All rights reserved.