E
- the element typepublic class ExceptionWatchdogImpl<E extends Exception> extends Object implements ExceptionWatchdog<E>
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 and Description |
---|
ExceptionWatchdogImpl() |
Modifier and Type | Method and Description |
---|---|
void |
catchException()
This methods awaits an
Exception . |
void |
dispose() |
E |
lastException()
Returns the last exception which was pushed via
ExceptionWatchdog.throwException(Exception) . |
void |
releaseAll() |
void |
throwException(E aException)
Passes an exception to the
ExceptionWatchdog notifying all
awaiting threads inside the ExceptionWatchdog.catchException() method to be
provided with that Exception . |
public void catchException() throws E extends Exception
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.catchException
in interface ExceptionWatchdog<E extends Exception>
catchException
in interface org.refcodes.exception.Exceptional<E extends Exception>
E
- Thrown when a next exception has been provided via
ExceptionWatchdog.throwException(Exception)
;E extends Exception
public E lastException()
ExceptionWatchdog.throwException(Exception)
. THis might not be the same as being
retrieved by ExceptionWatchdog.catchException()
, as ExceptionWatchdog.catchException()
might provide queued up Exception
instances till all
Exception
instances have been processed.lastException
in interface ExceptionWatchdog<E extends Exception>
lastException
in interface org.refcodes.exception.Exceptional<E extends Exception>
ExceptionWatchdog.throwException(Exception)
;public void throwException(E aException)
ExceptionWatchdog
notifying all
awaiting threads inside the ExceptionWatchdog.catchException()
method to be
provided with that Exception
.throwException
in interface ExceptionWatchdog<E extends Exception>
aException
- The Exception
to be passed to the awaiting
threads inside the ExceptionWatchdog.catchException()
method.public void releaseAll()
releaseAll
in interface org.refcodes.mixin.Releaseable
public void dispose()
dispose
in interface org.refcodes.mixin.Disposable
Copyright © 2017. All rights reserved.