Klasse SanityChecks

java.lang.Object
speiger.src.collections.utils.SanityChecks

public class SanityChecks extends Object
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

    Felder
    Modifizierer und Typ
    Feld
    Beschreibung
    static final int
    Max Possible ArraySize without the JVM Crashing
  • Konstruktorübersicht

    Konstruktoren
    Konstruktor
    Beschreibung
     
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    static boolean
    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 Random
     
    static void
    A Helper method to start a Async Task.
    static <T> void
    Helper method to start a ForkJoinTask.
    static <T> void
    Helper method to start a ForkJoinTask.
    static boolean
    Helper method to detect if the Current Thread forces not to await task completion.
    static boolean
    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
    Helper method to decide if Parallelism should be checked or not.
    static void
    Helper method to control what ForkJoinPool is being used for any given task.

    Von Klasse geerbte Methoden java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Felddetails

    • MAX_ARRAY_SIZE

      public static final int MAX_ARRAY_SIZE
      Max 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 Array
      offset - the offset of the access
      accessSize - 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

      public static <T> void invokeTask(ForkJoinTask<T> task)
      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

      public static <T> void invokeAsyncTask(ForkJoinTask<T> task)
      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

      public static void invokeAsyncTask(Runnable task)
      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

      public static void setWorkPool(ForkJoinPool pool)
      Helper method to control what ForkJoinPool is being used for any given task.
      Parameter:
      pool - The ForkJoinPool that should receive the tasks. If null ForkJoinPool.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

      public static Random getRandom()
      Gibt zurück:
      Thread Specific Random needed for internal functions in this library.