1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-19 08:52:15 +01:00

Wrap the discoverers into separate threads

Fixes #6350 (the regression was introduced with b2241dadf8f7777564bc5595265caa53a1fec399 )
Thanks git-bisect :)
This commit is contained in:
Martino Facchin 2017-09-22 17:35:32 +02:00
parent 1f9d99b699
commit 52c829fb0d
4 changed files with 14 additions and 4 deletions

View File

@ -31,7 +31,7 @@ package cc.arduino.packages;
import java.util.List;
public interface Discovery {
public interface Discovery extends Runnable {
/**
* Start discovery service

View File

@ -51,7 +51,7 @@ public class DiscoveryManager {
// Start all discoverers
for (Discovery d : discoverers) {
try {
d.start();
new Thread(d).start();
} catch (Exception e) {
System.err.println(tr("Error starting discovery method: ") + d.getClass());
e.printStackTrace();

View File

@ -39,7 +39,7 @@ import java.util.*;
import cc.arduino.packages.discoverers.network.BoardReachabilityFilter;
public class NetworkDiscovery implements Discovery, ServiceListener {
public class NetworkDiscovery implements Discovery, ServiceListener, Runnable {
private final List<BoardPort> reachableBoardPorts = new LinkedList<>();
private final List<BoardPort> boardPortsDiscoveredWithJmDNS = new LinkedList<>();
@ -138,6 +138,11 @@ public class NetworkDiscovery implements Discovery, ServiceListener {
}
@Override
public void run() {
start();
}
@Override
public void start() {
jmdns = JmmDNS.Factory.getInstance();

View File

@ -37,7 +37,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Timer;
public class SerialDiscovery implements Discovery {
public class SerialDiscovery implements Discovery, Runnable {
private Timer serialBoardsListerTimer;
private final List<BoardPort> serialBoardPorts;
@ -85,6 +85,11 @@ public class SerialDiscovery implements Discovery {
public void pausePolling(boolean param) { serialBoardsLister.pausePolling = param;}
@Override
public void run() {
start();
}
@Override
public void start() {
this.serialBoardsListerTimer = new Timer(SerialBoardsLister.class.getName());