[New] Added check to not set Action to execution state if already executed in ExecutionPolicy.setActionState()
This commit is contained in:
parent
380f5b6597
commit
0b2df5a3b4
|
@ -20,6 +20,7 @@ import li.strolch.privilege.model.PrivilegeContext;
|
|||
import li.strolch.runtime.StrolchConstants;
|
||||
import li.strolch.runtime.privilege.PrivilegedRunnable;
|
||||
import li.strolch.runtime.privilege.PrivilegedRunnableWithResult;
|
||||
import li.strolch.utils.time.PeriodDuration;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
@ -246,6 +247,9 @@ public abstract class ExecutionPolicy extends StrolchPolicy {
|
|||
* @param state the new state to set
|
||||
*/
|
||||
protected void setActionState(Action action, State state) {
|
||||
if (action.getState().inClosedPhase())
|
||||
throw new IllegalStateException("Action " + action.getLocator() + " has state " + action.getState() +
|
||||
" and can not be changed to " + state);
|
||||
|
||||
action.setState(state);
|
||||
|
||||
|
@ -270,6 +274,17 @@ public abstract class ExecutionPolicy extends StrolchPolicy {
|
|||
return action.findObjectivesParam(PARAM_DURATION, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delays the given {@link Runnable} by the given {@link PeriodDuration}
|
||||
*
|
||||
* @param duration the duration to delay
|
||||
* @param runnable the action to delay
|
||||
*/
|
||||
public void delay(PeriodDuration duration, Runnable runnable) {
|
||||
long delayMs = duration.toMillis();
|
||||
getDelayedExecutionTimer().delay(delayMs, runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delays the given {@link Runnable} by the given {@link Duration}
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue