Skip to content

Commit

Permalink
use singleThreadExecutor instead of custom executor, fizes getgauge/g…
Browse files Browse the repository at this point in the history
  • Loading branch information
sriv committed Apr 28, 2020
1 parent 697d487 commit f07d5cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 52 deletions.
21 changes: 9 additions & 12 deletions src/main/java/com/thoughtworks/gauge/execution/ExecutorPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,29 @@

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ExecutorPool {
private Map<String, TaskExecutor> executors = new HashMap<>();
private Map<String, ExecutorService> executors = new HashMap<>();

public ExecutorPool(int size) {
for (int count = 1; count <= size; count++) {
String threadName = getName(count);
TaskExecutor executor = new TaskExecutor(threadName);
executors.put(threadName, executor);
executor.start();
executors.put(getName(count), Executors.newSingleThreadExecutor());
}
}

private String getName(int count) {
return "Executor-" + count;
}

public void execute(int stream, Runnable task) throws Exception {
executors.get(getName(stream)).submitTask(task);
public void execute(int stream, Runnable task) {
executors.get(getName(stream)).execute(task);
}

public void stopAfterCompletion() throws InterruptedException {
for (Map.Entry<String, TaskExecutor> entry : executors.entrySet()) {
TaskExecutor value = entry.getValue();
value.stopThread();
value.join();
public void stopAfterCompletion() {
for (Map.Entry<String, ExecutorService> entry : executors.entrySet()) {
entry.getValue().shutdown();
}
}
}
40 changes: 0 additions & 40 deletions src/main/java/com/thoughtworks/gauge/execution/TaskExecutor.java

This file was deleted.

0 comments on commit f07d5cc

Please sign in to comment.