(input)
| 114 | |
| 115 | //Callback for when input is received from job.input() |
| 116 | var handle_input = function (input) { |
| 117 | if (typeof input !== 'undefined' && input !== null && input !== false) { |
| 118 | master.emit('input', input, for_worker); |
| 119 | } else { |
| 120 | |
| 121 | //No input? We might be done.. |
| 122 | |
| 123 | var isComplete = function () { |
| 124 | //Check if any input was added dynamically |
| 125 | if (job.input.length > 0) { |
| 126 | job.is_complete = false; |
| 127 | return false; |
| 128 | } |
| 129 | |
| 130 | //Wait for workers or instances that are still working |
| 131 | return worker_count > 0 ? areWorkersComplete() : job.instances <= 0; |
| 132 | }; |
| 133 | |
| 134 | //If we're not complete, check periodically |
| 135 | if (isComplete()) { |
| 136 | master.emit('complete'); |
| 137 | } else { |
| 138 | completeCheckInterval = setInterval(function () { |
| 139 | if (isComplete()) { |
| 140 | clearInterval(completeCheckInterval); |
| 141 | master.emit('complete'); |
| 142 | } |
| 143 | }, 300); |
| 144 | } |
| 145 | } |
| 146 | }; |
| 147 | |
| 148 | if (pull > 0) { |
| 149 |
no test coverage detected