made the board hashmap concurrent

This commit is contained in:
Federico Fissore 2013-04-05 10:48:33 +02:00
parent ad866ca5ed
commit ae852f8ab1
4 changed files with 9 additions and 7 deletions

View File

@ -27,6 +27,7 @@ import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import javax.jmdns.ServiceEvent;
import javax.swing.*;
@ -116,7 +117,7 @@ public class Base {
// int editorCount;
List<Editor> editors = Collections.synchronizedList(new ArrayList<Editor>());
Editor activeEditor;
final Map<String, Map<String, Object>> boardsViaNetwork;
private final Map<String, Map<String, Object>> boardsViaNetwork;
static File portableFolder = null;
static final String portableSketchbookFolder = "sketchbook";
@ -257,7 +258,7 @@ public class Base {
public Base(String[] args) throws Exception {
platform.init(this);
this.boardsViaNetwork = new HashMap<String, Map<String, Object>>();
this.boardsViaNetwork = new ConcurrentHashMap<String, Map<String, Object>>();
// Get the sketchbook path, and make sure it's set properly
String sketchbookPath = Preferences.get("sketchbook.path");
@ -423,6 +424,9 @@ public class Base {
});
}
public Map<String, Map<String, Object>> getBoardsViaNetwork() {
return new HashMap<String, Map<String, Object>>(boardsViaNetwork);
}
/**
* Post-constructor setup for the editor area. Loads the last

View File

@ -1004,7 +1004,7 @@ public class Editor extends JFrame implements RunnerListener {
exception.printStackTrace();
}
for (Map.Entry<String, Map<String, Object>> entry : base.boardsViaNetwork.entrySet()) {
for (Map.Entry<String, Map<String, Object>> entry : base.getBoardsViaNetwork().entrySet()) {
Inet4Address[] a = (Inet4Address[]) entry.getValue().get("addresses");
String label = entry.getKey() + "@" + a[0].toString();
JCheckBoxMenuItem rbMenuItem = new JCheckBoxMenuItem(label, label.equals(Preferences.get("serial.port")));

View File

@ -2,10 +2,7 @@ package processing.app.zeroconf;
import processing.app.zeroconf.jmdns.ArduinoDNSTaskStarter;
import javax.jmdns.JmDNS;
import javax.jmdns.NetworkTopologyDiscovery;
import javax.jmdns.ServiceEvent;
import javax.jmdns.ServiceListener;
import javax.jmdns.*;
import javax.jmdns.impl.DNSTaskStarter;
import java.io.IOException;
import java.net.InetAddress;

View File

@ -18,6 +18,7 @@ public class ArduinoDNSTaskStarter implements DNSTaskStarter.Factory.ClassDelega
public void purgeTimer() {
delegate.purgeTimer();
timer.purge();
}
public void purgeStateTimer() {