Changeset 1006
- Timestamp:
- 07/31/08 03:02:54 (1 month ago)
- Files:
-
- trunk/modules/cothread.jsm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/modules/cothread.jsm
r1005 r1006 78 78 * ).run(); 79 79 * 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 thread80 * @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 82 82 * @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) 83 83 */ 84 84 function CoThread(func, yieldEvery, thisCtx) { 85 85 CoThreadBase.call(this, func, yieldEvery, thisCtx); 86 87 // fake generator so we may use a common implementation. ;) 86 88 this._generator = (function() { for(;;) { yield null }; })(); 87 89 } … … 92 94 _ran: false, 93 95 94 run: function () {96 run: function CoThread_run() { 95 97 if (this._ran) { 96 98 throw new Error("You cannot run a CoThread/CoThreadListWalker instance more than once."); 97 99 } 98 100 this._ran = true; 101 99 102 this._timer = new Timer(this, 10, TYPE_REPEATING_SLACK); 100 103 }, … … 129 132 }, 130 133 131 _callf: function CoThread_ callf(ctx, item, idx, func) {134 _callf: function CoThread__callf(ctx, item, idx, func) { 132 135 return func.call(ctx, idx); 133 136 } … … 155 158 * ).run(); 156 159 * 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 list159 * @param { Object} yieldEvery Optional. After how many items control should be turned over to the main thread160 * @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 160 163 * @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) 161 164 */ … … 179 182 CoThreadListWalker.prototype[x] = CoThread.prototype[x]; 180 183 } 181 CoThreadListWalker.prototype._callf = function CoThreadListWalker_ callf(ctx, item, idx, func) {184 CoThreadListWalker.prototype._callf = function CoThreadListWalker__callf(ctx, item, idx, func) { 182 185 return func.call(ctx, item, idx); 183 186 }
