MCPcopy
hub / github.com/caolan/async / runTask

Function runTask

lib/auto.js:192–223  ·  view source on GitHub ↗
(key, task)

Source from the content-addressed store, hash-verified

190
191
192 function runTask(key, task) {
193 if (hasError) return;
194
195 var taskCallback = onlyOnce(rest(function(err, args) {
196 runningTasks--;
197 if (args.length <= 1) {
198 args = args[0];
199 }
200 if (err) {
201 var safeResults = {};
202 forOwn(results, function(val, rkey) {
203 safeResults[rkey] = val;
204 });
205 safeResults[key] = args;
206 hasError = true;
207 listeners = Object.create(null);
208
209 callback(err, safeResults);
210 } else {
211 results[key] = args;
212 taskComplete(key);
213 }
214 }));
215
216 runningTasks++;
217 var taskFn = wrapAsync(task[task.length - 1]);
218 if (task.length > 1) {
219 taskFn(results, taskCallback);
220 } else {
221 taskFn(taskCallback);
222 }
223 }
224
225 function checkForDeadlocks() {
226 // Kahn's algorithm

Callers 1

enqueueTaskFunction · 0.85

Calls 5

onlyOnceFunction · 0.85
restFunction · 0.85
taskCompleteFunction · 0.85
wrapAsyncFunction · 0.85
taskFnFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…