Skip to content

Commit

Permalink
entryActions instead of entryAction
Browse files Browse the repository at this point in the history
  • Loading branch information
miho committed Feb 23, 2023
1 parent 3b04e0b commit 589b9d1
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -692,27 +692,28 @@ private void performStateTransition(Event evt, State oldState, State newState, T
try {

// execute entry-action
StateAction entryAction = s.getOnEntryAction();
var oldS = s.getOwningFSM().getCurrentState();
if (entryAction != null) {
var entryActions = s.getOnEntryActions();
for(var entryAction : entryActions) {
if (entryAction != null) {

try {
fsmLock.unlock();
//entryAction.execute(s, evt);
CompletableFuture.runAsync(() -> {
try {
fsmLock.unlock();
//entryAction.execute(s, evt);
CompletableFuture.runAsync(() -> {
fsmLock.lock();
try {
entryAction.execute(s, evt);
} finally {
s.getOwningFSM().setCurrentState(s);
fsmLock.unlock();
}
}, executorService).orTimeout(MAX_ENTER_ACTION_TIMEOUT, TimeUnit.MILLISECONDS).get();
} finally {
fsmLock.lock();
try {
entryAction.execute(s, evt);
} finally {
s.getOwningFSM().setCurrentState(s);
fsmLock.unlock();
}
},executorService).orTimeout(MAX_ENTER_ACTION_TIMEOUT, TimeUnit.MILLISECONDS).get();
} finally {
fsmLock.lock();
}
}
}

if (!((FSMExecutor)s.getOwningFSM().getExecutor()).executeDoActionOfNewState(evt, oldS, s)) return;
// if (!executeDoActionOfNewState(evt, s, newState)) return;

Expand Down Expand Up @@ -743,23 +744,24 @@ private void performStateTransition(Event evt, State oldState, State newState, T

// execute on-entry action
try {
StateAction entryAction = newState.getOnEntryAction();
if (entryAction != null) {
try {
fsmLock.unlock();
CompletableFuture.runAsync(() -> {
var entryActions = newState.getOnEntryActions();
for (var entryAction : entryActions) {
if (entryAction != null) {
try {
fsmLock.unlock();
CompletableFuture.runAsync(() -> {
fsmLock.lock();
try {
entryAction.execute(newState, evt);
} finally {
fsmLock.unlock();
}
}, executorService).orTimeout(MAX_ENTER_ACTION_TIMEOUT, TimeUnit.MILLISECONDS).get();
} finally {
fsmLock.lock();
try {
entryAction.execute(newState, evt);
} finally {
fsmLock.unlock();
}
},executorService).orTimeout(MAX_ENTER_ACTION_TIMEOUT, TimeUnit.MILLISECONDS).get();
} finally {
fsmLock.lock();
}
}
}

} catch (Exception ex) {
handleExecutionError(evt, oldState, newState, ex);
return;
Expand Down
Loading

0 comments on commit 589b9d1

Please sign in to comment.