E
- the element typeorg.refcodes.exception.Exceptional<E>
, org.refcodes.mixin.Disposable
, org.refcodes.mixin.Releaseable
public class ExceptionWatchdog<E extends Exception> extends Object implements org.refcodes.exception.Exceptional<E>, org.refcodes.mixin.Disposable, org.refcodes.mixin.Releaseable
ExceptionWatchdog
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 | Description |
---|---|
ExceptionWatchdog() |
Modifier and Type | Method | Description |
---|---|---|
void |
catchException() |
This methods awaits an
Exception . |
void |
dispose() |
|
E |
lastException() |
Returns the last exception which was pushed via
throwException(Exception) . |
void |
releaseAll() |
|
void |
throwException(E aException) |
Passes an exception to the
ExceptionWatchdog notifying all
awaiting threads inside the catchException() method to be
provided with that Exception . |
public void catchException() throws E extends Exception
Exception
. It waits (sleeps) until an
Exception
arises via throwException(Exception)
which is
then thrown by this catchException()
method. In case
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.public E lastException()
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.lastException
in interface org.refcodes.exception.Exceptional<E extends Exception>
throwException(Exception)
;public void throwException(E aException)
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.public void releaseAll()
releaseAll
in interface org.refcodes.mixin.Releaseable
public void dispose()
dispose
in interface org.refcodes.mixin.Disposable
Copyright © 2021. All rights reserved.