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 + "]");
|
||||
}
|
||||
|
||||
Future f = LinkManager.COMMUNICATION_EXECUTOR.submit(new Runnable() {
|
||||
Future f = LinkManager.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sendTextCommand(command);
|
||||
|
@ -139,7 +139,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
|||
while (!isClosed) {
|
||||
// FileLog.rlog("queue: " + LinkManager.COMMUNICATION_QUEUE.toString());
|
||||
if (LinkManager.COMMUNICATION_QUEUE.isEmpty()) {
|
||||
LinkManager.COMMUNICATION_EXECUTOR.submit(new Runnable() {
|
||||
LinkManager.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (requestOutputChannels())
|
||||
|
|
|
@ -40,6 +40,14 @@ public class LinkManager {
|
|||
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 {
|
||||
INFO,
|
||||
DEBUG,
|
||||
|
@ -87,12 +95,23 @@ public class LinkManager {
|
|||
private static Thread COMMUNICATION_THREAD;
|
||||
|
||||
static {
|
||||
COMMUNICATION_EXECUTOR.submit(new Runnable() {
|
||||
/*
|
||||
Future future = submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// WAT? this is hanging?!
|
||||
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() {
|
||||
|
|
|
@ -23,7 +23,7 @@ public class SerialConnector implements LinkConnector {
|
|||
FileLog.MAIN.logLine("SerialConnector: connecting");
|
||||
portHolder.listener = listener;
|
||||
FileLog.MAIN.logLine("scheduleOpening");
|
||||
LinkManager.COMMUNICATION_EXECUTOR.execute(new Runnable() {
|
||||
LinkManager.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FileLog.MAIN.logLine("scheduleOpening>openPort");
|
||||
|
@ -34,7 +34,7 @@ public class SerialConnector implements LinkConnector {
|
|||
|
||||
@Override
|
||||
public void restart() {
|
||||
LinkManager.COMMUNICATION_EXECUTOR.execute(new Runnable() {
|
||||
LinkManager.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MessagesCentral.getInstance().postMessage(getClass(), "Restarting serial IO");
|
||||
|
|
|
@ -86,7 +86,7 @@ public class UploadChanges {
|
|||
public static void scheduleUpload(final ConfigurationImage newVersion, final Runnable afterUpload) {
|
||||
JFrame frame = wnd.getFrame();
|
||||
frame.setVisible(true);
|
||||
LinkManager.COMMUNICATION_EXECUTOR.execute(new Runnable() {
|
||||
LinkManager.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue