Fix the readInputLoop so that messages are all delivered and processed in the main thread

This commit is contained in:
Guillaume Nodet
2020-11-12 00:18:06 +01:00
parent e397627376
commit d44e3201e0
5 changed files with 27 additions and 5 deletions

View File

@@ -129,6 +129,14 @@ public class DaemonClientConnection implements Closeable {
}
}
public void enqueue(Message message) {
try {
queue.put(message);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
protected void doReceive() {
try {
while (running.get()) {

View File

@@ -199,7 +199,8 @@ public class DefaultClient implements Client {
final DaemonConnector connector = new DaemonConnector(parameters, registry);
try (DaemonClientConnection daemon = connector.connect(output)) {
output.setDeamonDispatch(daemon::dispatch);
output.setDaemonDispatch(daemon::dispatch);
output.setDaemonReceive(daemon::enqueue);
output.accept(Message.buildStatus("Connected to daemon"));
daemon.dispatch(new Message.BuildRequest(