Interface ExceptionWatchdog<E extends Exception>

  • Type Parameters:
    E - the element type
    All Superinterfaces:
    org.refcodes.mixin.Disposable, org.refcodes.exception.Exceptional<E>, org.refcodes.mixin.Releaseable
    All Known Implementing Classes:
    ExceptionWatchdogImpl


    public interface ExceptionWatchdog<E extends Exception>
    extends org.refcodes.exception.Exceptional<E>, org.refcodes.mixin.Disposable, org.refcodes.mixin.Releaseable
    The ExceptionWatchdog allows any number of threads to wait (sleep) when calling catchException() till the ExceptionWatchdog is fed with a next Exception with throwException(Exception) or till all waiting threads are released by calling Releaseable.releaseAll().

    Depending in the implementation, either just the current exception is passed to the catchException() method or a FIFO queue may be used passing all queued Exception instances to the catchException() method as soon as a thread is awaiting an Exception.

    • Method Detail

      • catchException

        void catchException​()
                     throws E extends Exception
        This methods awaits an Exception. It waits (sleeps) until an Exception arises via throwException(Exception) which is then thrown by this 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 Exception>
        Throws:
        E - Thrown when a next exception has been provided via throwException(Exception);
        E extends Exception