avoid queuing a lot of threads while waiting for platform

This commit is contained in:
Martino Facchin 2016-04-06 17:52:24 +02:00
parent 72c337d88d
commit bf11c7f395
1 changed files with 8 additions and 7 deletions

View File

@ -56,13 +56,6 @@ public class SerialBoardsLister extends TimerTask {
}
public synchronized void retriggerDiscovery(boolean polled) {
while (BaseNoGui.packages == null) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// noop
}
}
Platform platform = BaseNoGui.getPlatform();
if (platform == null) {
return;
@ -103,6 +96,11 @@ public class SerialBoardsLister extends TimerTask {
String[] parts = newPort.split("_");
String port = parts[0];
if (parts.length != 3) {
// something went horribly wrong
continue;
}
Map<String, Object> boardData = platform.resolveDeviceByVendorIdProductId(port, BaseNoGui.packages);
BoardPort boardPort = null;
@ -168,6 +166,9 @@ public class SerialBoardsLister extends TimerTask {
@Override
public void run() {
if (BaseNoGui.packages == null) {
return;
}
retriggerDiscovery(true);
}
}