reducing complexity
This commit is contained in:
parent
e3ee77b58a
commit
b447e23f97
|
@ -88,7 +88,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
||||||
CommunicationLoggingHolder.communicationLoggingListener.onPortHolderMessage(BinaryProtocol.class, "Sending [" + command + "]");
|
CommunicationLoggingHolder.communicationLoggingListener.onPortHolderMessage(BinaryProtocol.class, "Sending [" + command + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
Future f = LinkManager.COMMUNICATION_EXECUTOR.submit(new Runnable() {
|
Future f = LinkManager.submit(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
sendTextCommand(command);
|
sendTextCommand(command);
|
||||||
|
@ -139,7 +139,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
||||||
while (!isClosed) {
|
while (!isClosed) {
|
||||||
// FileLog.rlog("queue: " + LinkManager.COMMUNICATION_QUEUE.toString());
|
// FileLog.rlog("queue: " + LinkManager.COMMUNICATION_QUEUE.toString());
|
||||||
if (LinkManager.COMMUNICATION_QUEUE.isEmpty()) {
|
if (LinkManager.COMMUNICATION_QUEUE.isEmpty()) {
|
||||||
LinkManager.COMMUNICATION_EXECUTOR.submit(new Runnable() {
|
LinkManager.submit(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (requestOutputChannels())
|
if (requestOutputChannels())
|
||||||
|
|
|
@ -40,6 +40,14 @@ public class LinkManager {
|
||||||
return connected;
|
return connected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void execute(Runnable runnable) {
|
||||||
|
COMMUNICATION_EXECUTOR.execute(runnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Future submit(Runnable runnable) {
|
||||||
|
return COMMUNICATION_EXECUTOR.submit(runnable);
|
||||||
|
}
|
||||||
|
|
||||||
public enum LogLevel {
|
public enum LogLevel {
|
||||||
INFO,
|
INFO,
|
||||||
DEBUG,
|
DEBUG,
|
||||||
|
@ -87,12 +95,23 @@ public class LinkManager {
|
||||||
private static Thread COMMUNICATION_THREAD;
|
private static Thread COMMUNICATION_THREAD;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
COMMUNICATION_EXECUTOR.submit(new Runnable() {
|
/*
|
||||||
|
Future future = submit(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
// WAT? this is hanging?!
|
||||||
COMMUNICATION_THREAD = Thread.currentThread();
|
COMMUNICATION_THREAD = Thread.currentThread();
|
||||||
|
System.out.println("Done");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
try {
|
||||||
|
// let's wait for the above trivial task to finish
|
||||||
|
future.get();
|
||||||
|
System.out.println("Done2");
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void assertCommunicationThread() {
|
public static void assertCommunicationThread() {
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class SerialConnector implements LinkConnector {
|
||||||
FileLog.MAIN.logLine("SerialConnector: connecting");
|
FileLog.MAIN.logLine("SerialConnector: connecting");
|
||||||
portHolder.listener = listener;
|
portHolder.listener = listener;
|
||||||
FileLog.MAIN.logLine("scheduleOpening");
|
FileLog.MAIN.logLine("scheduleOpening");
|
||||||
LinkManager.COMMUNICATION_EXECUTOR.execute(new Runnable() {
|
LinkManager.execute(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
FileLog.MAIN.logLine("scheduleOpening>openPort");
|
FileLog.MAIN.logLine("scheduleOpening>openPort");
|
||||||
|
@ -34,7 +34,7 @@ public class SerialConnector implements LinkConnector {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void restart() {
|
public void restart() {
|
||||||
LinkManager.COMMUNICATION_EXECUTOR.execute(new Runnable() {
|
LinkManager.execute(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MessagesCentral.getInstance().postMessage(getClass(), "Restarting serial IO");
|
MessagesCentral.getInstance().postMessage(getClass(), "Restarting serial IO");
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class UploadChanges {
|
||||||
public static void scheduleUpload(final ConfigurationImage newVersion, final Runnable afterUpload) {
|
public static void scheduleUpload(final ConfigurationImage newVersion, final Runnable afterUpload) {
|
||||||
JFrame frame = wnd.getFrame();
|
JFrame frame = wnd.getFrame();
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
LinkManager.COMMUNICATION_EXECUTOR.execute(new Runnable() {
|
LinkManager.execute(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue