Interface ExceptionWatchdog<E extends java.lang.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:

    public interface ExceptionWatchdog<E extends java.lang.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.

    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.refcodes.mixin.Disposable

    • Method Detail

      • catchException

        void catchException​()
                     throws E extends java.lang.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 java.lang.Exception>
        E - Thrown when a next exception has been provided via throwException(Exception);
        E extends java.lang.Exception
      • lastException

        E lastException​()
        Returns the last exception which was pushed via throwException(Exception). THis might not be the same as being retrieved by catchException(), as catchException() might provide queued up Exception instances till all Exception instances have been processed.
        Specified by:
        lastException in interface org.refcodes.exception.Exceptional<E extends java.lang.Exception>
        The last exception being pushed via throwException(Exception);
      • throwException

        void throwException​(E aException)
        Passes an exception to the ExceptionWatchdog notifying all awaiting threads inside the catchException() method to be provided with that Exception.
        aException - The Exception to be passed to the awaiting threads inside the catchException() method.