Changeset 1006

Show
Ignore:
Timestamp:
07/31/08 03:02:54 (1 month ago)
Author:
MaierMan
Message:

Some more comments and function naming

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/modules/cothread.jsm

    r1005 r1006  
    7878 *        ).run(); 
    7979 *    
    80  * @param {Object} func Function to be called. Is passed call count as argument. Returning false will cancel the operation.  
    81  * @param {Object} yieldEvery Optional. After how many items control should be turned over to the main thread 
     80 * @param {Function} func Function to be called. Is passed call count as argument. Returning false will cancel the operation.  
     81 * @param {Number} yieldEvery Optional. After how many items control should be turned over to the main thread 
    8282 * @param {Object} thisCtx Optional. The function will be called in the scope of this object (or if omitted in the scope of the CoThread instance) 
    8383 */ 
    8484function CoThread(func, yieldEvery, thisCtx) { 
    8585        CoThreadBase.call(this, func, yieldEvery, thisCtx); 
     86         
     87        // fake generator so we may use a common implementation. ;) 
    8688        this._generator = (function() { for(;;) { yield null }; })(); 
    8789} 
     
    9294        _ran: false, 
    9395         
    94         run: function() { 
     96        run: function CoThread_run() { 
    9597                if (this._ran) { 
    9698                        throw new Error("You cannot run a CoThread/CoThreadListWalker instance more than once."); 
    9799                } 
    98100                this._ran = true; 
     101                 
    99102                this._timer = new Timer(this, 10, TYPE_REPEATING_SLACK);                 
    100103        }, 
     
    129132        }, 
    130133         
    131         _callf: function CoThread_callf(ctx, item, idx, func) { 
     134        _callf: function CoThread__callf(ctx, item, idx, func) { 
    132135                return func.call(ctx, idx); 
    133136        } 
     
    155158 *        ).run(); 
    156159 *    
    157  * @param {Object} func Function to be called on each item. Is passed item and index as arguments. Returning false will cancel the operation.  
    158  * @param {Object} arrayOrGenerator Array or Generator object to be used as the input list  
    159  * @param {Object} yieldEvery Optional. After how many items control should be turned over to the main thread 
     160 * @param {Function} func Function to be called on each item. Is passed item and index as arguments. Returning false will cancel the operation.  
     161 * @param {Array/Generator} arrayOrGenerator Array or Generator object to be used as the input list  
     162 * @param {Number} yieldEvery Optional. After how many items control should be turned over to the main thread 
    160163 * @param {Object} thisCtx Optional. The function will be called in the scope of this object (or if omitted in the scope of the CoThread instance) 
    161164 */ 
     
    179182        CoThreadListWalker.prototype[x] = CoThread.prototype[x]; 
    180183} 
    181 CoThreadListWalker.prototype._callf = function CoThreadListWalker_callf(ctx, item, idx, func) { 
     184CoThreadListWalker.prototype._callf = function CoThreadListWalker__callf(ctx, item, idx, func) { 
    182185        return func.call(ctx, item, idx); 
    183186}