(fn, taskType)
| 21293 | self.notifyWhenNoPendingTasks = notifyWhenNoPendingTasks; |
| 21294 | |
| 21295 | function completeTask(fn, taskType) { |
| 21296 | taskType = taskType || DEFAULT_TASK_TYPE; |
| 21297 | |
| 21298 | try { |
| 21299 | fn(); |
| 21300 | } finally { |
| 21301 | decTaskCount(taskType); |
| 21302 | |
| 21303 | var countForType = taskCounts[taskType]; |
| 21304 | var countForAll = taskCounts[ALL_TASKS_TYPE]; |
| 21305 | |
| 21306 | // If at least one of the queues (`ALL_TASKS_TYPE` or `taskType`) is empty, run callbacks. |
| 21307 | if (!countForAll || !countForType) { |
| 21308 | var getNextCallback = !countForAll ? getLastCallback : getLastCallbackForType; |
| 21309 | var nextCb; |
| 21310 | |
| 21311 | while ((nextCb = getNextCallback(taskType))) { |
| 21312 | try { |
| 21313 | nextCb(); |
| 21314 | } catch (e) { |
| 21315 | log.error(e); |
| 21316 | } |
| 21317 | } |
| 21318 | } |
| 21319 | } |
| 21320 | } |
| 21321 | |
| 21322 | function decTaskCount(taskType) { |
| 21323 | taskType = taskType || DEFAULT_TASK_TYPE; |
nothing calls this directly
no test coverage detected