|
ProgramixGenericLib v5.0.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.programix.thread.InitializationMonitor
public class InitializationMonitor
This class serves as a thread-safe way to monitor the initialization of a component in a system.
This monitor starts off in the "in progress" state and ends up in either one of two states: "success" or "failure". Only on state transition occurs (they state either goes from "in progress" to "success" or it goes from "in progress" to "failed"). There is no way to "reset" or "retry"—that is, the state never returns to "in progress".
Nested Class Summary | |
---|---|
static class |
InitializationMonitor.FailedException
Thrown by some methods on InitializationMonitor
to indicate that the initialization failed. |
Constructor Summary | |
---|---|
InitializationMonitor()
Creates a monitor that starts off in the "in progress" state and locks on this instance. |
|
InitializationMonitor(Object lockObject)
Creates a monitor that starts off in the "in progress" state. |
|
InitializationMonitor(Waiter waiter)
Creates a monitor that starts off in the "in progress" state. |
Method Summary | |
---|---|
void |
indicateFailure()
Mark the initialization as complete but a failure. |
void |
indicateFailureIfNotSuccess()
Mark the initialization as complete but a failure if it has not already been marked as a success. |
void |
indicateSuccess()
Mark the initialization as complete and successful. |
void |
indicateSuccessIfNotFailure()
Mark the initialization as complete and successful if it has not already been marked as a failure. |
boolean |
isFailure()
Returns true if the initialization is complete but failed. |
boolean |
isInProgress()
Returns true while the initialization is still "in progress". |
boolean |
isSuccess()
Returns true if the initialization is complete and was successful. |
void |
waitUntilSuccess()
Waits until the initialization has completed successfully. |
void |
waitUntilSuccess(long msTimeout)
Waits until the initialization has completed successfully. |
void |
waitWhileInProgress()
Waits until the initialization is completed—whether it is successful or a failure. |
void |
waitWhileInProgress(long msTimeout)
Waits until the initialization is completed—whether it is successful or a failure. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public InitializationMonitor(Waiter waiter)
waiter
- the Waiter
to use.
If null, then a new Waiter
is automatically created.public InitializationMonitor(Object lockObject)
lockObject
- the object to synchronize on.
If null, the the synchronization will be on this instance.public InitializationMonitor()
Method Detail |
---|
public boolean isInProgress()
public boolean isSuccess()
public boolean isFailure()
public void indicateSuccess() throws IllegalStateException
IllegalStateException
- if the state is not currently
"in progress".public void indicateSuccessIfNotFailure() throws IllegalStateException
IllegalStateException
- if the state is already "failure".public void indicateFailure() throws IllegalStateException
IllegalStateException
- if the state is not currently
"in progress".public void indicateFailureIfNotSuccess() throws IllegalStateException
IllegalStateException
- if the state is already "success".public void waitUntilSuccess(long msTimeout) throws InitializationMonitor.FailedException, InterruptException, TimedOutException
InitializationMonitor.FailedException
is
thrown.
msTimeout
- the maximum number of ms to wait
InitializationMonitor.FailedException
- if the initialization completed, but was a
failure.
InterruptException
- if interrupted while waiting
TimedOutException
- if the time runs out and it is still
"in progress".public void waitUntilSuccess() throws InitializationMonitor.FailedException, InterruptException
InitializationMonitor.FailedException
is
thrown.
InitializationMonitor.FailedException
- if the initialization completed, but was a
failure.
InterruptException
- if interrupted while waitingpublic void waitWhileInProgress(long msTimeout) throws InterruptException, TimedOutException
isSuccess()
and/or call
isFailure()
to find out the result when no
longer "in progress".
msTimeout
- the maximum number of ms to wait
InterruptException
- if interrupted while waiting
TimedOutException
- if the time runs out and it is still
"in progress".public void waitWhileInProgress() throws InterruptException
isSuccess()
and/or call
isFailure()
to find out the result when no
longer "in progress".
InterruptException
- if interrupted while waiting
|
ProgramixGenericLib v5.0.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |