| 168 | } |
| 169 | |
| 170 | void waited(const Future<T>& future) |
| 171 | { |
| 172 | if (future.isFailed()) { |
| 173 | promise->fail("Collect failed: " + future.failure()); |
| 174 | terminate(this); |
| 175 | } else if (future.isDiscarded()) { |
| 176 | promise->fail("Collect failed: future discarded"); |
| 177 | terminate(this); |
| 178 | } else { |
| 179 | CHECK_READY(future); |
| 180 | ready += 1; |
| 181 | if (ready == futures.size()) { |
| 182 | std::vector<T> values; |
| 183 | values.reserve(futures.size()); |
| 184 | |
| 185 | foreach (const Future<T>& future, futures) { |
| 186 | values.push_back(future.get()); |
| 187 | } |
| 188 | |
| 189 | promise->set(std::move(values)); |
| 190 | terminate(this); |
| 191 | } |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | const std::vector<Future<T>> futures; |
| 196 | Promise<std::vector<T>>* promise; |