|
Class AsyncExecHelper
|
get method) and will allow clients to control
NOTE: although it is possible to apply the helper to any
SyncManagedExectuables it is not recommended since the sync functions will
intoduce unnecessary overhead
Example:
void startSystem(AsyncManagedExecutable a, AsyncManagedExecutable b, AsyncManagedExecutable c) throws SomeException {
try {
// start a and b
ExecStateFuture aStartFuture = AsyncExecHelper.start(a);
ExecStateFuture bStartFuture = AsyncExecHelper.start(b);
// wait for a and b to finish starting before starting c
ExecState aStartResult = aStartFuture.get();
if(!ExecState.RUNNING.equals(aStartResult)) {
throw new SomeException(ce);
}
ExecState aStartResult = aStartFuture.get();
if(!ExecState.RUNNING.equals(aStartResult)) {
throw new SomeException(ce);
}
// start c
ExecStateFuture cStartFuture = AsyncExecHelper.start(c);
// wait for c to finish starting before returning
cStartFuture.get();
ExecState cStartResult = cStartFuture.get();
if(!ExecState.RUNNING.equals(cStartResult)) {
throw new SomeException(ce);
}
} catch(CancellationException ce) {
throw new SomeException(ce);
} catch(InvalidStateException ise) {
throw new SomeException(ise);
} catch(ExecutableException exee) {
throw new SomeException(exee);
} catch(ExecutionException exe) {
throw new SomeException(exe);
}
}
| Method Summary | |
|---|---|
public static ExecStateFuture |
resume(ManagedExecutable mgdExec) |
public static ExecStateFuture |
shutdown(ManagedExecutable mgdExec) |
public static ExecStateFuture |
start(ManagedExecutable mgdExec) |
public static ExecStateFuture |
stop(ManagedExecutable mgdExec) |
public static ExecStateFuture |
suspend(ManagedExecutable mgdExec) |