You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of the current approach that uses CustomDuplication and relies on a specific order in which the instances get initialized and the controllerStarted callback invoked, do something as suggested by @ianroberts
private MLEngine[] engineHolder;
@Sharable
// getter and setter for engineHolder
public Resource init() {
if(engineHolder == null) {
engineHolder = new MLEngine[1];
}
}
public void reInit() {
engineHolder = null;
}
public void controllerExecutionStarted() {
synchronized(ThisClass.class) {
if(engineHolder[0] == null) {
engineHolder[0] = createEngine();
engineOwner = true;
} else {
engineOwner = false;
}
}
}
public void execute() {
// guaranteed to be not-null,
MLEngine engine = engineHolder[0];
}
public void controllerExecutionFinished() {
if(engineOwner) {
doStuffWith(engineHolder[0]);
}
}
The text was updated successfully, but these errors were encountered:
Instead of the current approach that uses CustomDuplication and relies on a specific order in which the instances get initialized and the controllerStarted callback invoked, do something as suggested by @ianroberts
The text was updated successfully, but these errors were encountered: