Skip to content
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

Initialize Enso Terminal in a background thread #11149

Merged
merged 1 commit into from
Sep 24, 2024
Merged
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
22 changes: 17 additions & 5 deletions engine/runner/src/main/java/org/enso/runner/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -959,12 +962,21 @@ private void runRepl(
}

private static MessageTransport replTransport() {
var repl = new Repl(makeTerminalForRepl());
ThreadFactory factory = (r) -> new Thread(r, "Initialize Enso Terminal");
var executor = Executors.newSingleThreadExecutor(factory);
var futureRepl = executor.submit(() -> new Repl(makeTerminalForRepl()));
MessageTransport transport =
(uri, peer) ->
DebugServerInfo.URI.equals(uri.toString())
? new DebuggerSessionManagerEndpoint(repl, peer)
: null;
(uri, peer) -> {
if (DebugServerInfo.URI.equals(uri.toString())) {
try {
var repl = futureRepl.get();
return new DebuggerSessionManagerEndpoint(repl, peer);
} catch (InterruptedException | ExecutionException ex) {
logger.error("Cannot initialize REPL transport", ex);
}
}
return null;
};
return transport;
}

Expand Down
Loading