mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-09-27 07:55:25 +00:00
Fix the readInputLoop so that messages are all delivered and processed in the main thread
This commit is contained in:
@@ -24,7 +24,9 @@ import org.jboss.fuse.mvnd.common.Message;
|
||||
*/
|
||||
public interface ClientOutput extends AutoCloseable {
|
||||
|
||||
void setDeamonDispatch(Consumer<Message> sink);
|
||||
void setDaemonDispatch(Consumer<Message> sink);
|
||||
|
||||
void setDaemonReceive(Consumer<Message> sink);
|
||||
|
||||
void accept(Message message);
|
||||
|
||||
|
@@ -69,6 +69,8 @@ public class TerminalOutput implements ClientOutput {
|
||||
|
||||
/** A sink for sending messages back to the daemon */
|
||||
private volatile Consumer<Message> daemonDispatch;
|
||||
/** A sink for queuing messages to the main queue */
|
||||
private volatile Consumer<Message> daemonReceive;
|
||||
|
||||
/*
|
||||
* The following non-final fields are read/written from the main thread only.
|
||||
@@ -131,10 +133,15 @@ public class TerminalOutput implements ClientOutput {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeamonDispatch(Consumer<Message> daemonDispatch) {
|
||||
public void setDaemonDispatch(Consumer<Message> daemonDispatch) {
|
||||
this.daemonDispatch = daemonDispatch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDaemonReceive(Consumer<Message> daemonReceive) {
|
||||
this.daemonReceive = daemonReceive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(Message entry) {
|
||||
assert "main".equals(Thread.currentThread().getName());
|
||||
@@ -356,7 +363,7 @@ public class TerminalOutput implements ClientOutput {
|
||||
break;
|
||||
}
|
||||
if (c == '+' || c == '-' || c == CTRL_L || c == CTRL_M || c == CTRL_B) {
|
||||
accept(Message.keyboardInput((char) c));
|
||||
daemonReceive.accept(Message.keyboardInput((char) c));
|
||||
}
|
||||
readInput.readLock().unlock();
|
||||
}
|
||||
|
Reference in New Issue
Block a user