public class SanityChecks
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_ARRAY_SIZE
Max Possible ArraySize without the JVM Crashing
|
| Constructor and Description |
|---|
SanityChecks() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
canParallelTask()
Returns if the current thread-pool can handle Multi-threading tasks
|
static byte |
castToByte(int value)
Internal function to cast a Integer to a Byte
|
static char |
castToChar(int value)
Internal function to cast a Integer to a Character
|
static float |
castToFloat(double value)
Internal function to cast a Double to a Double
|
static short |
castToShort(int value)
Internal function to cast a Integer to a Short
|
static void |
checkArrayCapacity(int arraySize,
int offset,
int accessSize)
Internal function that checks if the given array-size is big enough for the access.
|
static java.util.Random |
getRandom() |
static <T> void |
invokeAsyncTask(java.util.concurrent.ForkJoinTask<T> task)
Helper method to start a ForkJoinTask.
|
static void |
invokeAsyncTask(java.lang.Runnable task)
A Helper method to start a Async Task.
|
static <T> void |
invokeTask(java.util.concurrent.ForkJoinTask<T> task)
Helper method to start a ForkJoinTask.
|
static boolean |
isForcedAsync()
Helper method to detect if the Current Thread forces not to await task completion.
|
static boolean |
isForcedTaskPool()
Helper method to detect if the current thread forces to execute tasks in the current Thread-pool if it is a ForkJoinPool.
|
static void |
setForcedAsync(boolean value)
Helper method to decide if the current thread should forcefully not wait on tasks to be completed.
|
static void |
setForcedTaskPool(boolean value)
Helper method to decide if it should be checked for if the current thread is a ThreadPool Worker (ForkJoinPool Worker to be specific) and if tasks should be delegated into it.
|
static void |
setForceIgnoreParallelism(boolean value)
Helper method to decide if Parallelism should be checked or not.
|
static void |
setWorkPool(java.util.concurrent.ForkJoinPool pool)
Helper method to control what ForkJoinPool is being used for any given task.
|
public static final int MAX_ARRAY_SIZE
public static byte castToByte(int value)
value - that should be turned into a bytejava.lang.IllegalStateException - if the value does not fit within a bytepublic static short castToShort(int value)
value - that should be turned into a shortjava.lang.IllegalStateException - if the value does not fit within a shortpublic static char castToChar(int value)
value - that should be turned into a charjava.lang.IllegalStateException - if the value does not fit within a charpublic static float castToFloat(double value)
value - that should be turned into a floatjava.lang.IllegalStateException - if the value does not fit within a floatpublic static void checkArrayCapacity(int arraySize,
int offset,
int accessSize)
arraySize - the size of the Arrayoffset - the offset of the accessaccessSize - the length of the accessjava.lang.IllegalStateException - if offset or accessSize is negative or the range goes out of the array-sizepublic static boolean canParallelTask()
public static <T> void invokeTask(java.util.concurrent.ForkJoinTask<T> task)
T - the type of the tasktask - the Task to invokepublic static <T> void invokeAsyncTask(java.util.concurrent.ForkJoinTask<T> task)
T - the type of the tasktask - the Task to invokepublic static void invokeAsyncTask(java.lang.Runnable task)
task - the Task to invokepublic static void setWorkPool(java.util.concurrent.ForkJoinPool pool)
pool - The ForkJoinPool that should receive the tasks. If null ForkJoinPool.commonPool() is set insteadpublic static boolean isForcedAsync()
public static boolean isForcedTaskPool()
public static void setForcedAsync(boolean value)
value - it tasks should not be awaited forpublic static void setForcedTaskPool(boolean value)
value - if the current thread should check if it is a ThreadPoolWorker.public static void setForceIgnoreParallelism(boolean value)
value - if the Parallelism should be ignoredpublic static java.util.Random getRandom()