java.lang.Object
speiger.src.collections.utils.SanityChecks
Helper class that provides functions that are shared within the library.
On top of that it provides some helper functions that allow control of some internals of the Library
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungstatic final intMax Possible ArraySize without the JVM Crashing -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic booleanReturns if the current thread-pool can handle Multi-threading tasksstatic bytecastToByte(int value) Internal function to cast a Integer to a Bytestatic charcastToChar(int value) Internal function to cast a Integer to a Characterstatic floatcastToFloat(double value) Internal function to cast a Double to a Doublestatic shortcastToShort(int value) Internal function to cast a Integer to a Shortstatic voidcheckArrayCapacity(int arraySize, int offset, int accessSize) Internal function that checks if the given array-size is big enough for the access.static Randomstatic voidinvokeAsyncTask(Runnable task) A Helper method to start a Async Task.static <T> voidinvokeAsyncTask(ForkJoinTask<T> task) Helper method to start a ForkJoinTask.static <T> voidinvokeTask(ForkJoinTask<T> task) Helper method to start a ForkJoinTask.static booleanHelper method to detect if the Current Thread forces not to await task completion.static booleanHelper method to detect if the current thread forces to execute tasks in the current Thread-pool if it is a ForkJoinPool.static voidsetForcedAsync(boolean value) Helper method to decide if the current thread should forcefully not wait on tasks to be completed.static voidsetForcedTaskPool(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 voidsetForceIgnoreParallelism(boolean value) Helper method to decide if Parallelism should be checked or not.static voidsetWorkPool(ForkJoinPool pool) Helper method to control what ForkJoinPool is being used for any given task.
-
Felddetails
-
MAX_ARRAY_SIZE
public static final int MAX_ARRAY_SIZEMax Possible ArraySize without the JVM Crashing- Siehe auch:
-
-
Konstruktordetails
-
SanityChecks
public SanityChecks()
-
-
Methodendetails
-
castToByte
public static byte castToByte(int value) Internal function to cast a Integer to a Byte- Parameter:
value- that should be turned into a byte- Gibt zurück:
- the value as a byte
- Löst aus:
IllegalStateException- if the value does not fit within a byte
-
castToShort
public static short castToShort(int value) Internal function to cast a Integer to a Short- Parameter:
value- that should be turned into a short- Gibt zurück:
- the value as a short
- Löst aus:
IllegalStateException- if the value does not fit within a short
-
castToChar
public static char castToChar(int value) Internal function to cast a Integer to a Character- Parameter:
value- that should be turned into a char- Gibt zurück:
- the value as a char
- Löst aus:
IllegalStateException- if the value does not fit within a char
-
castToFloat
public static float castToFloat(double value) Internal function to cast a Double to a Double- Parameter:
value- that should be turned into a float- Gibt zurück:
- the value as a float
- Löst aus:
IllegalStateException- if the value does not fit within a float
-
checkArrayCapacity
public static void checkArrayCapacity(int arraySize, int offset, int accessSize) Internal function that checks if the given array-size is big enough for the access.- Parameter:
arraySize- the size of the Arrayoffset- the offset of the accessaccessSize- the length of the access- Löst aus:
IllegalStateException- if offset or accessSize is negative or the range goes out of the array-size
-
canParallelTask
public static boolean canParallelTask()Returns if the current thread-pool can handle Multi-threading tasks- Gibt zurück:
- true if the thread-count is bigger the 1
-
invokeTask
Helper method to start a ForkJoinTask. This method will await the finalization of said task- Typparameter:
T- the type of the task- Parameter:
task- the Task to invoke
-
invokeAsyncTask
Helper method to start a ForkJoinTask. This method will not await the finalization of said task- Typparameter:
T- the type of the task- Parameter:
task- the Task to invoke
-
invokeAsyncTask
A Helper method to start a Async Task. This method will not await the finalization of said task- Parameter:
task- the Task to invoke
-
setWorkPool
Helper method to control what ForkJoinPool is being used for any given task.- Parameter:
pool- The ForkJoinPool that should receive the tasks. If nullForkJoinPool.commonPool()is set instead- Note:
- this method is not thread-save. It is only there to provide control over how Library specific Threaded tasks are handled.
-
isForcedAsync
public static boolean isForcedAsync()Helper method to detect if the Current Thread forces not to await task completion.- Gibt zurück:
- if the Current Thread has not to await task completion.
-
isForcedTaskPool
public 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.- Gibt zurück:
- if the task checks the current pool to be executed in if it is valid.
-
setForcedAsync
public static void setForcedAsync(boolean value) Helper method to decide if the current thread should forcefully not wait on tasks to be completed.- Parameter:
value- it tasks should not be awaited for
-
setForcedTaskPool
public 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.- Parameter:
value- if the current thread should check if it is a ThreadPoolWorker.
-
setForceIgnoreParallelism
public static void setForceIgnoreParallelism(boolean value) Helper method to decide if Parallelism should be checked or not.- Parameter:
value- if the Parallelism should be ignored
-
getRandom
- Gibt zurück:
- Thread Specific Random needed for internal functions in this library.
-