Skip to content

Commit

Permalink
documentation improved
Browse files Browse the repository at this point in the history
  • Loading branch information
miho committed Nov 3, 2021
1 parent 0f6effc commit b0256d0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
* An async executor for state machines.
*/
public class Executor implements eu.mihosoft.vsm.model.AsyncExecutor {

private final Deque<Event> evtQueue = new ConcurrentLinkedDeque<>();
Expand Down Expand Up @@ -78,7 +81,7 @@ private Executor(FSM fsm, ExecutionMode mode, int depth, Executor parent) {
}

/**
* Creates a new executor instance.
* Creates a new async executor instance.
* @param fsm the fsm to execute
* @param mode the execution mode
* @return the new executor instance
Expand Down Expand Up @@ -134,6 +137,7 @@ public void triggerFirst(Event event) {
}
}

@Override
public boolean process(Event evt) {

if(executorRunning.get()) {
Expand All @@ -151,6 +155,7 @@ public boolean process(Event evt) {
}
}

@Override
public boolean process(String evt, EventConsumedAction onConsumed, Object... args) {

if(executorRunning.get()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ default void trigger(String evt, Object... args) {

/**
* Triggers and processes the specified event. The executor of the state machine must
* not be running (via {@link Executor#isRunning()}) if this method should be used.
* not be running (via {@link Executor#isRunning()}) if this method is used to process events.
* This method returns as soon as the triggered event and events created as consequence
* of triggering this event have been processed.
* @param evt event identifier
Expand All @@ -64,6 +64,28 @@ default void trigger(String evt, Object... args) {
*/
boolean process(String evt, Object... args);

/**
* Triggers and processes the specified event. The executor of the state machine must
* not be running (via {@link Executor#isRunning()}) if this method is used to process events.
* This method returns as soon as the triggered event and events created as consequence
* of triggering this event have been processed.
* @param evt event identifier
* @return {@code true} if the method processed events; {@code false} otherwise
*/
public boolean process(Event evt);

/**
* Triggers and processes the specified event. The executor of the state machine must
* not be running (via {@link Executor#isRunning()}) if this method is used to process events.
* This method returns as soon as the triggered event and events created as consequence
* of triggering this event have been processed.
* @param evt event identifier
* @param onConsumed an optional action that is executed if and when the event is consumed
* @param args optional event arguments
* @return {@code true} if the method processed events; {@code false} otherwise
*/
public boolean process(String evt, EventConsumedAction onConsumed, Object... args);

/**
* Processes events that are on the event queue and haven't been processed yet.
* @return {@code true} if the method processed events; {@code false} otherwise
Expand Down Expand Up @@ -128,6 +150,8 @@ default void trigger(String evt, Object... args) {

/**
* Events triggered by the state machine.
*
* <p><b>Caution: </b>Do not trigger these events manually.</p>
*/
enum FSMEvents {

Expand Down

0 comments on commit b0256d0

Please sign in to comment.