Skip to content

Start an execution engine without a new Java thread #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -313,42 +313,47 @@ public final void start() {

@Override
public void run() {
try {
notifyEngineAboutToStart();
Activator.getDefault().gemocRunningEngineRegistry.registerEngine(getName(), AbstractExecutionEngine.this);
setEngineStatus(EngineStatus.RunStatus.Running);
beforeStart();
notifyEngineStarted();
try {
performStart();
} finally {
// We always try to commit the last remaining
// transaction
commitCurrentTransaction();
}

} catch (EngineStoppedException stopException) {
// not really an error, simply print the stop exception
// message
Activator.getDefault().info("Engine stopped by the user : " + stopException.getMessage());

} catch (Throwable e) {
error = e;
e.printStackTrace();
Activator.getDefault().error("Exception received " + e.getMessage() + ", stopping engine.", e);
} finally {
// make sure to notify the stop if this wasn't an
// external call to stop() that lead us here.
// ie. normal end of the mode execution
stop();
Activator.getDefault().info("*** " + AbstractExecutionEngine.this.getName() + " stopped ***");
}
startSynchronous();
}
};
thread = new Thread(r, engineKindName() + " " + _executionContext.getRunConfiguration().getExecutedModelURI());
thread.start();
}
}

@Override
public final void startSynchronous() {
try {
notifyEngineAboutToStart();
Activator.getDefault().gemocRunningEngineRegistry.registerEngine(getName(), AbstractExecutionEngine.this);
setEngineStatus(EngineStatus.RunStatus.Running);
beforeStart();
notifyEngineStarted();
try {
performStart();
} finally {
// We always try to commit the last remaining
// transaction
commitCurrentTransaction();
}

} catch (EngineStoppedException stopException) {
// not really an error, simply print the stop exception
// message
Activator.getDefault().info("Engine stopped by the user : " + stopException.getMessage());

} catch (Throwable e) {
error = e;
e.printStackTrace();
Activator.getDefault().error("Exception received " + e.getMessage() + ", stopping engine.", e);
} finally {
// make sure to notify the stop if this wasn't an
// external call to stop() that lead us here.
// ie. normal end of the mode execution
stop();
Activator.getDefault().info("*** " + AbstractExecutionEngine.this.getName() + " stopped ***");
}
}

@Override
public final void stop() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,6 @@ default LaunchConfiguration extractLaunchConfiguration() {
* @return a display name to identify this engine
*/
String getName();

void startSynchronous();
}