public interface ExceptionWatchdog<E extends Exception>
extends org.refcodes.exception.Exceptional<E>, org.refcodes.mixin.Disposable, org.refcodes.mixin.Releaseable
ExceptionWatchdog
allows any number of threads to wait (sleep)
when calling #onException()
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 #onException()
method or a FIFO queue may be used passing all
queued Exception
instances to the #onException()
method as
soon as a thread is awaiting an Exception
.
Modifier and Type | Method and Description |
---|---|
void |
catchException()
This methods awaits an
Exception . |
E |
lastException()
Returns the last exception which was pushed via
throwException(Exception) . |
void |
throwException(E aException)
Passes an exception to the
ExceptionWatchdog notifying all
awaiting threads inside the #onException() method to be provided
with that Exception . |
void catchException() throws E extends Exception
Exception
. It waits (sleeps) until an
Exception
arises via throwException(Exception)
which is
then thrown by this #onException()
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.catchException
in interface org.refcodes.exception.Exceptional<E extends Exception>
E
- Thrown when a next exception has been provided via
throwException(Exception)
;E extends Exception
E lastException()
throwException(Exception)
. THis might not be the same as being
retrieved by #onException()
, as #onException()
might
provide queued up Exception
instances till all Exception
instances have been processed.lastException
in interface org.refcodes.exception.Exceptional<E extends Exception>
throwException(Exception)
;void throwException(E aException)
ExceptionWatchdog
notifying all
awaiting threads inside the #onException()
method to be provided
with that Exception
.aException
- The Exception
to be passed to the awaiting
threads inside the #onException()
method.Copyright © 2016. All rights reserved.