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:
parent
1f9d99b699
commit
52c829fb0d
@ -31,7 +31,7 @@ package cc.arduino.packages;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface Discovery {
|
public interface Discovery extends Runnable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start discovery service
|
* Start discovery service
|
||||||
|
@ -51,7 +51,7 @@ public class DiscoveryManager {
|
|||||||
// Start all discoverers
|
// Start all discoverers
|
||||||
for (Discovery d : discoverers) {
|
for (Discovery d : discoverers) {
|
||||||
try {
|
try {
|
||||||
d.start();
|
new Thread(d).start();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println(tr("Error starting discovery method: ") + d.getClass());
|
System.err.println(tr("Error starting discovery method: ") + d.getClass());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -39,7 +39,7 @@ import java.util.*;
|
|||||||
|
|
||||||
import cc.arduino.packages.discoverers.network.BoardReachabilityFilter;
|
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> reachableBoardPorts = new LinkedList<>();
|
||||||
private final List<BoardPort> boardPortsDiscoveredWithJmDNS = 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
|
@Override
|
||||||
public void start() {
|
public void start() {
|
||||||
jmdns = JmmDNS.Factory.getInstance();
|
jmdns = JmmDNS.Factory.getInstance();
|
||||||
|
@ -37,7 +37,7 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
|
|
||||||
public class SerialDiscovery implements Discovery {
|
public class SerialDiscovery implements Discovery, Runnable {
|
||||||
|
|
||||||
private Timer serialBoardsListerTimer;
|
private Timer serialBoardsListerTimer;
|
||||||
private final List<BoardPort> serialBoardPorts;
|
private final List<BoardPort> serialBoardPorts;
|
||||||
@ -85,6 +85,11 @@ public class SerialDiscovery implements Discovery {
|
|||||||
|
|
||||||
public void pausePolling(boolean param) { serialBoardsLister.pausePolling = param;}
|
public void pausePolling(boolean param) { serialBoardsLister.pausePolling = param;}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start() {
|
public void start() {
|
||||||
this.serialBoardsListerTimer = new Timer(SerialBoardsLister.class.getName());
|
this.serialBoardsListerTimer = new Timer(SerialBoardsLister.class.getName());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user