chiark / gitweb /
thread fixes: debugging from UIX
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 2 Apr 2011 17:34:32 +0000 (18:34 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 2 Apr 2011 17:34:32 +0000 (18:34 +0100)
src/net/chiark/yarrg/MarketUploader.java

index 4f50228a7b77f8131902fb5e19228500322f3725..4e78282de05079d205058e1ba38d35879118aaf6 100644 (file)
@@ -254,7 +254,7 @@ implements Runnable, TopLevelWindowListener, GUIInitializedListener {
       if (arb != null && arb.length() != 0)
        s = "<html>" + arb + "<br>" + s;
       progmon.setNote(s);
-    }}.exec();
+    }}.exec("progressNote");
   }
        
   /*
@@ -374,7 +374,7 @@ implements Runnable, TopLevelWindowListener, GUIInitializedListener {
                    progmon = null;
                  }
                  findMarket.setEnabled(true);
-               }}.exec();
+               }}.exec("tidying");
              } catch (Exception e) {
                System.err.println("exception tidying on UI thread:");
                e.printStackTrace();
@@ -408,12 +408,22 @@ implements Runnable, TopLevelWindowListener, GUIInitializedListener {
   private abstract class UIXR<ReturnType> implements Runnable {
     public abstract ReturnType bodyr();
     public ReturnType return_value;
-    public void run() { return_value = bodyr(); };
-    public ReturnType exec() throws Exception {
+    private String what;
+    public void run() { 
+      debuglog("UIX 2 "+what+" begin");
+      return_value = bodyr();
+      debuglog("UIX 3 "+what+" done");
+    };
+    public ReturnType exec(String what_in) throws Exception {
+      what = what_in;
       if (EventQueue.isDispatchThread()) {
+       debuglog("UIX 1 "+what+" (event thread) entry");
        this.run();
+       debuglog("UIX 4 "+what+" (event thread) exit");
       } else {
+       debuglog("UIX 1 "+what+" (other thread) entry");
        EventQueue.invokeAndWait(this);
+       debuglog("UIX 4 "+what+" (other thread) exit");
       }
       return return_value;
     };
@@ -432,7 +442,7 @@ implements Runnable, TopLevelWindowListener, GUIInitializedListener {
        resultSummary.setText("failed");
        JOptionPane.showMessageDialog(frame,msg,"Error",
                                      JOptionPane.ERROR_MESSAGE);
-      }}.exec();
+      }}.exec("error()");
     } catch (Exception e) {
       System.err.println("exception reporting to UI thread:");
       e.printStackTrace();
@@ -461,12 +471,12 @@ implements Runnable, TopLevelWindowListener, GUIInitializedListener {
   private void setProgress(final int nv) throws Exception {
     new UIX() { public void body() {
       progmon.setProgress(nv);
-    }}.exec();
+    }}.exec("setProgress");
   }
   private boolean isCanceled() throws Exception {
     return new UIXR<Boolean>() { public Boolean bodyr() {
       return new Boolean(progmon.isCanceled());
-    }}.exec().booleanValue();
+    }}.exec("isCanceled").booleanValue();
   }
        
   /*
@@ -618,7 +628,7 @@ implements Runnable, TopLevelWindowListener, GUIInitializedListener {
       debuglog("getocean done");
 
       return at;
-    }}.exec();
+    }}.exec("accesstable");
     if (accesstable == null) return;
 
     if (latch != null) {
@@ -673,7 +683,7 @@ implements Runnable, TopLevelWindowListener, GUIInitializedListener {
       debuglog("table read...");
 
       return getData(accesstable);
-    }}.exec();
+    }}.exec("data");
     if (data == null) return;
 
     if (showArbitrage) {
@@ -784,7 +794,7 @@ implements Runnable, TopLevelWindowListener, GUIInitializedListener {
     final String summary_final = summary;
     new UIX() { public void body() {
       resultSummary.setText(summary_final);
-    }}.exec();
+    }}.exec("resultSummary.setText");
 
     debuglog("done.");
   }