Changeset 809

Show
Ignore:
Timestamp:
2008-02-29 21:20:04 (10 months ago)
Author:
MaierMan
Message:

put everything that belongs to the generator into the generator ;)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/serverswitcher/chrome/content/manager.js

    r808 r809  
    9898                        } 
    9999                         
    100                         let cset = {}; 
    101                         // Count the running task 
    102                         Dialog._running.forEach( 
    103                                 function(i) { 
    104                                         let host = i.d._ssw_host; 
    105                                         if (!(host in cset)) { 
    106                                                 cset[host] = new SSWItem(host); 
    107                                         } 
    108                                         else { 
    109                                                 cset[host].inc(); 
    110                                         } 
    111                                 }, 
    112                                 this 
    113                         ); 
    114                         for (d in SSW._generator(cset)) { 
     100                        for (d in SSW._generator()) { 
    115101                                if (this._running.length >= Prefs.maxInProgress) { 
    116102                                        break; 
     
    126112                return false;    
    127113        }, 
    128         _generator: function(downloadSet) { 
     114        _generator: function() { 
     115                        let downloadSet = {}; 
     116                         
     117                        // Count the running tasks 
     118                        Dialog._running.forEach( 
     119                                function(i) { 
     120                                        let host = i.d._ssw_host; 
     121                                        if (!(host in downloadSet)) { 
     122                                                downloadSet[host] = new SSWItem(host); 
     123                                        } 
     124                                        else { 
     125                                                downloadSet[host].inc(); 
     126                                        } 
     127                                }, 
     128                                this 
     129                        ); 
     130         
    129131                for (let d in Tree.all) { 
    130132                        if (!d.is(QUEUED)) { 
     
    150152                } 
    151153                while (sorted.length) { 
     154                         
     155                        // short-circut 
     156                        if (sorted.length == 1) { 
     157                                let s = sorted.shift(); 
     158                                while (s.available) { 
     159                                        yield s.pop(); 
     160                                }                
     161                                return; 
     162                        } 
     163                         
    152164                        sorted.sort(SSWItem.prototype.cmp); 
    153165                        for (i in sorted) {