Class ExceptionWatchdogImpl<E extends java.lang.Exception>

  • Type Parameters:
    E - the element type
    All Implemented Interfaces:
    ExceptionWatchdog<E>, org.refcodes.exception.Exceptional<E>, org.refcodes.mixin.Disposable, org.refcodes.mixin.Releaseable

    public class ExceptionWatchdogImpl<E extends java.lang.Exception>
    extends java.lang.Object
    implements ExceptionWatchdog<E>
    The ExceptionWatchdogImpl implements a plain ExceptionWatchdog not queuing any Exception instances. Just the Exception instances thrown via throwException(Exception) are caught in case there is an awaiting thread inside the catchException() method.

    ATTENTION: This implementation is not 100% reliable whether very fast sequenced Exception instances fed to throwException(Exception) are all caught by threads awaiting the catchException() method calls! In cases you expect one exception and then "its over", this class does its job.

    • Constructor Detail

      • ExceptionWatchdogImpl

        public ExceptionWatchdogImpl​()
    • Method Detail

      • catchException

        public void catchException​()
                            throws E extends java.lang.Exception
        This methods awaits an Exception. It waits (sleeps) until an Exception arises via ExceptionWatchdog.throwException(Exception) which is then thrown by this ExceptionWatchdog.catchException() method. In case Releaseable.releaseAll() is being called, then all waiting threads are continued without throwing any exception. ------------------------------------------------------------------------- ATTENTION: In case waiting (sleeping) threads are released without throwing an Exception, then this means that the using instances intends to shut down so that in such as case, no more calls to this method are to be performed (are to be prevented), such looping threads would lead to endless looping and cause consumption of calculation power.
        Specified by:
        catchException in interface org.refcodes.exception.Exceptional<E extends java.lang.Exception>
        Specified by:
        catchException in interface ExceptionWatchdog<E extends java.lang.Exception>
        E - Thrown when a next exception has been provided via ExceptionWatchdog.throwException(Exception);
        E extends java.lang.Exception
      • releaseAll

        public void releaseAll​()
        Specified by:
        releaseAll in interface org.refcodes.mixin.Releaseable
      • dispose

        public void dispose​()
        Specified by:
        dispose in interface org.refcodes.mixin.Disposable