}
@Override
public Optional<Transition<S, C>> fire(E event) {
if (stateMachineLock.isHeldByCurrentThread()) {
throw new StateMachineException("StateMachine#fire(E) was called from within a synchronous Action or " +
"synchronous TransitionListener.\n" +
"Please use AsyncStateMachine#sumbit(E), " +
"AsyncStateMachine#inject(E), or an asynchronous Action or " +
"asynchronous TransitionListener.");
}
try {
return submit(event, priority.getAndIncrement()).get();
} catch (InterruptedException | ExecutionException e) {
throw new StateMachineException(e);
}
}