Changes between Version 1 and Version 2 of BackgroundJobs

Show
Ignore:
Timestamp:
11/04/09 23:53:32 (10 months ago)
Author:
marius (IP: 79.139.97.1)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BackgroundJobs

    v1 v2  
    11= `FolderChangeMonitor` = 
    2 The `FolderChangeMonitor` class is used to monitor changes on the current folder and to refresh that folder pane when a change occurs.  
    3 Each folder pane has its own monitor. Each monitor has a pause flag. When the monitor is paused the folder pane is not refreshed.  
     2The `FolderChangeMonitor` class is used to monitor changes on the current folder and to refresh that folder pane when a change occurs. [[BR]] 
     3Each folder pane has its own monitor. Each monitor has a pause flag. When the monitor is paused the folder pane is not refreshed. [[BR]] 
    44A monitor is paused for a pane when a job is executed, so the folder is not refreshed during the job execution. 
    5 When a job is being executed, the `ProgressDialog` is modal so you can't switch to another window to perform any other operations. 
    6 When we add an option to execute jobs in the background all monitors should be paused so that folders in different windows are not refreshed too frequently. 
    7 The pause flag is local to a folder pane, but we can make it global (static) to all panes. 
     5When a job is being executed, the `ProgressDialog` is modal so you can't switch to another window to perform any other operations.[[BR]] 
     6When we add an option to execute jobs in the background all monitors should be paused so that folders in different windows are not refreshed too frequently.[[BR]] 
     7The pause flag is local to a folder pane, but we can make it global (static) to all panes.[[BR]] 
    88When the first job starts all pane updates will be paused, when the last job from a queue stops, the pause flag will be cleared, and an active pane will be refreshed. 
    99 
    1010= `FileJob` = 
    11 The `FileJob` class is a base class for all jobs. 
     11The `FileJob` class is a base class for all jobs.[[BR]] 
    1212This class is not thread safe now. Each job is executed in its own thread. There are several fields that are read and written by different threads. 
    13 An example is `getState/setState` - a state of the job is updated in a job thread, but read in another thread (the thread that updates the UI). This method should be synchronized. 
     13An example is `getState/setState` - a state of the job is updated in a job thread, but read in another thread (the thread that updates the UI). This method should be synchronized.[[BR]] 
    1414The `setState` method notifies all listeners about state change. However, there are two problems: 
    15 a) the iterator is not thread safe - when a listener removes itself the state of iterator is undefined 
    16 b) listeners perform their actions in the job thread. Listeners can block the job thread. The action executed by the listener will probably update some UI information (like `ProgressDialog` now) so I think they should be executed in the Swing thread.  
    17 I think some methods from `FileJob` could be marked as final so that descendants of this class cannot override them as not synchronized. 
     15 a. the iterator is not thread safe - when a listener removes itself the state of iterator is undefined 
     16 b. listeners perform their actions in the job thread. Listeners can block the job thread. The action executed by the listener will probably update some UI information (like `ProgressDialog` now) so I think they should be executed in the Swing thread.  
     17I think some methods from `FileJob` could be marked as final so that descendants of this class cannot override them as not synchronized.[[BR]] 
    1818The methods that should be marked as synchronized are:      
    19        addFileJobListener, removeFileJobListener 
    20        getStartDate, getEndDate, getPauseStartDate, setPauseStartDate, getPausedTime, calcPausedTime, setPaused, getEffectiveJobTime, getCurrentFilename 
    21        getTotalPercentDone, getCurrentFileIndex, getCurrentFile, setCurrentFile, getNbFiles, setNbFiles, getStatusString 
    22        interrupt, stop 
     19 * addFileJobListener, removeFileJobListener 
     20 * getStartDate, getEndDate, getPauseStartDate, setPauseStartDate, getPausedTime, calcPausedTime, setPaused, getEffectiveJobTime, getCurrentFilename 
     21 * getTotalPercentDone, getCurrentFileIndex, getCurrentFile, setCurrentFile, getNbFiles, setNbFiles, getStatusString 
     22 * interrupt, stop 
    2323The `refreshTables` method enables the folder change monitor. It should be enabled only when there are no active background jobs. 
    2424         
    2525 
    2626= `TransferFileJob` = 
    27 The `TransferFileJob` class is a base class for all copy/move jobs. 
    28 Methods `getCurrentFileByteCounter, getTotalByteCounter, getTotalSkippedByteCounter` return a `ByteCounter` class.  
    29 It could be changed to return byte count (as long). The method `resetCurrentFileByteCounter` should be added to reset the byte counter. 
    30 Then we can synchronize these methods. 
     27The `TransferFileJob` class is a base class for all copy/move jobs.[[BR]] 
     28Methods `getCurrentFileByteCounter, getTotalByteCounter, getTotalSkippedByteCounter` return a `ByteCounter` class. [[BR]] 
     29It could be changed to return byte count (as long). The method `resetCurrentFileByteCounter` should be added to reset the byte counter.[[BR]] 
     30Then we can synchronize these methods.[[BR]] 
    3131Other methods that should be marked as synchronized are: 
    32    getFilePercentDone,getCurrentFileSize, 
    33    setThroughputLimit/getThroughputLimit 
     32 * getFilePercentDone,getCurrentFileSize, 
     33 * setThroughputLimit/getThroughputLimit 
    3434 
    3535 
    3636= UI changes = 
    37 On the job progress dialog add "in background" button. 
    38 When a background job is active show a spinning icon to the left of the trash button. 
     37On the job progress dialog add "in background" button.[[BR]] 
     38When a background job is active show a spinning icon to the left of the trash button.[[BR]] 
    3939Clicking on it shows a table with all background jobs. Clicking on a table row opens a progress dialog for a selected job.