Synchronize Join PseudoState state machine listener

- Synchronize JoinPseudoState's
  JoinTracker.stateChanged(State<S, E>, State<S, E>) method
  for playing nice with concurrent region execution.
  Should fix #93.
- Tuning test which relates to #76. What comes for the
  tests, there was this concurrency issue and also problem
  in tests itself.
- Polish JoinPseudoState.
This commit is contained in:
Janne Valkealahti
2015-08-07 14:38:17 +01:00
parent 4008436d75
commit bba3b231b3
3 changed files with 83 additions and 42 deletions

View File

@@ -33,9 +33,13 @@ import org.springframework.statemachine.state.PseudoStateContext.PseudoAction;
public class JoinPseudoState<S, E> extends AbstractPseudoState<S, E> {
private final List<State<S, E>> joins;
private volatile JoinTracker tracker;
/**
* Instantiates a new join pseudo state.
*
* @param joins the joins
*/
public JoinPseudoState(List<State<S, E>> joins) {
super(PseudoStateKind.JOIN);
this.joins = joins;
@@ -56,6 +60,11 @@ public class JoinPseudoState<S, E> extends AbstractPseudoState<S, E> {
tracker = null;
}
/**
* Gets the join states.
*
* @return the joins
*/
public List<State<S, E>> getJoins() {
return joins;
}
@@ -72,7 +81,7 @@ public class JoinPseudoState<S, E> extends AbstractPseudoState<S, E> {
}
@Override
public void stateChanged(State<S, E> from, State<S, E> to) {
public synchronized void stateChanged(State<S, E> from, State<S, E> to) {
if (!notified && track.size() > 0) {
track.remove(to);
if (track.size() == 0) {