Class BcThread

java.lang.Object
me.wobblyyyy.pathfinder.util.BcThread

public class BcThread
extends java.lang.Object
Utility class designed to deal with bad API versions - 1.8 vs 9, for example.
Since:
0.0.0
Author:
Colin Robertson
  • Field Summary

    Fields
    Modifier and Type Field Description
    private static java.lang.invoke.MethodHandle ON_SPIN_WAIT_HANDLE
    Handler for spin wait operation.
  • Constructor Summary

    Constructors
    Modifier Constructor Description
    private BcThread()
    Empty constructor - no construction here.
  • Method Summary

    Modifier and Type Method Description
    private static java.lang.invoke.MethodHandle resolve()
    Resolve the method for the onSpinWait() functionality.
    static boolean spin()
    If the current version of Java is above 9, indicating we have access to the Thread class's onSpinWait() method, we can simply call that method.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ON_SPIN_WAIT_HANDLE

      private static final java.lang.invoke.MethodHandle ON_SPIN_WAIT_HANDLE
      Handler for spin wait operation.
  • Constructor Details

    • BcThread

      private BcThread()
      Empty constructor - no construction here.
  • Method Details

    • resolve

      private static java.lang.invoke.MethodHandle resolve()
      Resolve the method for the onSpinWait() functionality.
      Returns:
      a method handle for the onSpinWait() method.
    • spin

      public static boolean spin()
      If the current version of Java is above 9, indicating we have access to the Thread class's onSpinWait() method, we can simply call that method. Otherwise, we just do absolutely nothing to prevent any exceptions from being thrown.
      Returns:
      whether or not the onSpinWait() method is working as originally intended. True if it's working, false if we have to use our own NOP method.