Skip to content

Commit

Permalink
extract EvalResult
Browse files Browse the repository at this point in the history
  • Loading branch information
brig committed Nov 20, 2024
1 parent 20255d6 commit 2700ec7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@
*/

import com.google.inject.Injector;
import com.walmartlabs.concord.svm.Runtime;
import com.walmartlabs.concord.svm.*;
import com.walmartlabs.concord.runtime.v2.runner.vm.LoggedException;
import com.walmartlabs.concord.svm.State;
import com.walmartlabs.concord.svm.ThreadId;
import com.walmartlabs.concord.svm.VM;
import com.walmartlabs.concord.svm.Runtime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -53,7 +51,7 @@ public void spawn(State state, ThreadId threadId) {
}

@Override
public VM.EvalResult eval(State state, ThreadId threadId) throws Exception {
public EvalResult eval(State state, ThreadId threadId) throws Exception {
try {
return vm.eval(this, state, threadId);
} catch (LoggedException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.walmartlabs.concord.svm;

import java.io.Serial;
import java.io.Serializable;

public class EvalResult implements Serializable {

@Serial
private static final long serialVersionUID = 1L;

private final Frame lastFrame;

public EvalResult(Frame lastFrame) {
this.lastFrame = lastFrame;
}

public Frame lastFrame() {
return lastFrame;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface Runtime {
*/
void spawn(State state, ThreadId threadId);

VM.EvalResult eval(State state, ThreadId threadId) throws Exception;
EvalResult eval(State state, ThreadId threadId) throws Exception;

/**
* Returns an instance of the specified service using the underlying injector.
Expand Down
20 changes: 2 additions & 18 deletions runtime/v2/vm/src/main/java/com/walmartlabs/concord/svm/VM.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -60,7 +59,7 @@ public void start(State state) throws Exception {
throw e;
}

listeners.fireAfterProcessEnds(runtime, state, result.lastFrame);
listeners.fireAfterProcessEnds(runtime, state, result.lastFrame());

log.debug("start -> done");
}
Expand Down Expand Up @@ -92,7 +91,7 @@ public void resume(State state, Set<String> eventRefs) throws Exception {
throw e;
}

listeners.fireAfterProcessEnds(runtime, state, result.lastFrame);
listeners.fireAfterProcessEnds(runtime, state, result.lastFrame());

log.debug("resume ['{}'] -> done", eventRefs);
}
Expand Down Expand Up @@ -249,19 +248,4 @@ private static void wakeSuspended(State state) {
}
}
}

public static class EvalResult implements Serializable {

private static final long serialVersionUID = 1L;

private final Frame lastFrame;

private EvalResult(Frame lastFrame) {
this.lastFrame = lastFrame;
}

public Frame lastFrame() {
return lastFrame;
}
}
}

0 comments on commit 2700ec7

Please sign in to comment.