- Timestamp:
- 2008-10-13T21:44:43+13:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/trunk/src/org/greenstone/gatherer/download/DownloadScrollPane.java
r12529 r17526 52 52 extends Thread { 53 53 54 /** <i>true</i> if there is a task currently being carried out, <i>false</i> otherwise. */55 private boolean busy = false;56 54 /** <i>true</i> if verbose debug messages should be displayed, <i>false</i> otherwise. */ 57 55 private boolean debug = false; … … 69 67 private Vector job_queue; 70 68 static final private boolean simple = true; 71 69 70 72 71 public DownloadScrollPane() { 73 72 job = null; … … 81 80 public void deleteDownloadJob(DownloadJob delete_me) { 82 81 if (delete_me == job) { 83 while(busy) { 84 } 82 try { 83 // Wait for the job to finish cleaning up, before we can continue cleaning up here. 84 // But sometimes the job has completed (terminated naturally) and in that case there's 85 // nothing to wait for. 86 synchronized(delete_me) { 87 if (!delete_me.hasSignalledStop()) { // don't wait if DownloadJob.COMPLETED 88 delete_me.wait(); 89 } 90 } 91 } catch (Exception e) { 92 e.printStackTrace(); 93 } 94 85 95 job = null; 86 } 96 97 } 98 // Get rid of this download's dedicated pane 99 finishedDownloadJob(delete_me); 100 } 101 102 /** To be called when a download job has terminated naturally or was prematurely stopped 103 * via the close button. Gets rid of this download's pane with buttons and progress bar. */ 104 protected void finishedDownloadJob(DownloadJob delete_me) { 87 105 if (delete_me.hasSignalledStop()) { 88 106 list_pane.remove(delete_me.getProgressBar()); … … 131 149 132 150 DebugStream.println("About to create a new job"); 133 134 151 135 152 DownloadJob new_job = new DownloadJob(download, Configuration.proxy_pass, Configuration.proxy_user, this, mode, proxy_url); 136 153 // Tell it to run as soon as possible 137 138 139 154 140 155 new_job.setState(DownloadJob.RUNNING); … … 165 180 //list_pane.setAlignmentX(Component.LEFT_ALIGNMENT); 166 181 list_pane.updateUI(); 167 new_job = null; 182 new_job = null; //job = (DownloadJob) job_queue.get(index); 183 168 184 synchronized(this) { 169 185 notify(); // Just incase its sleeping. … … 189 205 while(true) { 190 206 if(job_queue.size() > 0) { 191 int index = 0;192 while(job_queue.size() > 0 && index < job_queue.size()) {193 job = (DownloadJob) job_queue.get(index);207 while(!job_queue.isEmpty()) { 208 job = (DownloadJob) job_queue.firstElement(); 209 194 210 if(job.getState() == DownloadJob.RUNNING) { 195 DebugStream.println("DownloadJob " + job.toString() + " Begun."); 196 busy = true; 211 DownloadJob delete_me = job; 212 String jobDisplayString = job.toString(); 213 DebugStream.println("DownloadJob " + jobDisplayString + " Begun."); 214 System.err.println("DownloadJob " + job.port + " " + job.toString() + " Begun."); 197 215 job.callDownload(); 198 busy = false; 199 DebugStream.println("DownloadJob " + job.toString() + " complete."); 216 finishedDownloadJob(delete_me); // Job is done, get rid of the separate display panel for this download 217 System.err.println("DownloadJob " + jobDisplayString + " complete."); 218 DebugStream.println("DownloadJob " + jobDisplayString + " complete."); // by this point job is null! 200 219 job = null; 201 }202 index++;220 delete_me = null; 221 } 203 222 } 204 223 try {
Note:
See TracChangeset
for help on using the changeset viewer.