Class Interrupter


  • public class Interrupter
    extends java.lang.Object
    This class is used to conduct managed interrupts, which is essential for organized interrupts. In AILibs, it is generally forbidden to directly interrupt any thread. Instead, the Interrupter should be used, because this enables the interrupted thread to decide how to proceed. Using the Interrupter has several advantages in debugging: 1. the Interrupter tells which thread caused the interrupt 2. the Interrupter tells the time when the thread was interrupted 3. the Interrupter provides a reason for the interrupt
    • Method Detail

      • interruptThread

        public void interruptThread​(java.lang.Thread t,
                                    java.lang.Object reason)
      • hasCurrentThreadBeenInterruptedWithReason

        public boolean hasCurrentThreadBeenInterruptedWithReason​(java.lang.Object reason)
      • getInterruptOfCurrentThreadWithReason

        public java.util.Optional<Interrupt> getInterruptOfCurrentThreadWithReason​(java.lang.Object reason)
      • getInterruptOfThreadWithReason

        public java.util.Optional<Interrupt> getInterruptOfThreadWithReason​(java.lang.Thread thread,
                                                                            java.lang.Object reason)
      • avoidInterrupt

        public void avoidInterrupt​(java.lang.Thread t,
                                   java.lang.Object reason)
      • hasThreadBeenInterruptedWithReason

        public boolean hasThreadBeenInterruptedWithReason​(java.lang.Thread thread,
                                                          java.lang.Object reason)
      • getAllUnresolvedInterrupts

        public java.util.Collection<Interrupt> getAllUnresolvedInterrupts()
      • getAllUnresolvedInterruptsOfThread

        public java.util.Collection<Interrupt> getAllUnresolvedInterruptsOfThread​(java.lang.Thread thread)
      • getLatestUnresolvedInterruptOfThread

        public java.util.Optional<Interrupt> getLatestUnresolvedInterruptOfThread​(java.lang.Thread thread)
      • getLatestUnresolvedInterruptOfCurrentThread

        public java.util.Optional<Interrupt> getLatestUnresolvedInterruptOfCurrentThread()
      • hasCurrentThreadOpenInterrupts

        public boolean hasCurrentThreadOpenInterrupts()
      • markInterruptOnCurrentThreadAsResolved

        public void markInterruptOnCurrentThreadAsResolved​(java.lang.Object reason)
                                                    throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • markInterruptAsResolved

        public void markInterruptAsResolved​(java.lang.Thread t,
                                            java.lang.Object reason)