mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 16:53:04 +08:00
refactor(runner): change stdout/stderr reading thread into virtual thread in CommandExecutionService
This commit is contained in:
@@ -7,10 +7,14 @@ import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class CommandExecutionService {
|
||||
|
||||
private ExecutorService readerExecutor = Executors.newVirtualThreadPerTaskExecutor();
|
||||
|
||||
public String[] buildFileExecutionCommands(String launcher, Map<String, Object> params, String absolutePath) {
|
||||
int paramSize = params == null ? 0 : params.size();
|
||||
String[] commands = new String[paramSize + 2];
|
||||
@@ -57,8 +61,8 @@ public class CommandExecutionService {
|
||||
}
|
||||
});
|
||||
|
||||
stdoutThread.start();
|
||||
stderrThread.start();
|
||||
readerExecutor.execute(stdoutThread);
|
||||
readerExecutor.execute(stderrThread);
|
||||
|
||||
int exitCode = process.waitFor();
|
||||
stdoutThread.join();
|
||||
@@ -81,4 +85,8 @@ public class CommandExecutionService {
|
||||
private String total;
|
||||
private List<String> resultList;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class CommandSessionResult {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user