static
| 1322 | |
| 1323 | // static |
| 1324 | void Task::removeDriver(std::shared_ptr<Task> self, Driver* driver) { |
| 1325 | bool foundDriver = false; |
| 1326 | bool allFinished = true; |
| 1327 | EventCompletionNotifier stateChangeNotifier; |
| 1328 | { |
| 1329 | std::lock_guard<std::timed_mutex> taskLock(self->mutex_); |
| 1330 | for (auto& driverPtr : self->drivers_) { |
| 1331 | if (driverPtr.get() != driver) { |
| 1332 | continue; |
| 1333 | } |
| 1334 | |
| 1335 | // Mark the closure of another driver for its split group (even in |
| 1336 | // ungrouped execution mode). |
| 1337 | const auto splitGroupId = driver->driverCtx()->splitGroupId; |
| 1338 | auto& splitGroupState = self->splitGroupStates_[splitGroupId]; |
| 1339 | --splitGroupState.numRunningDrivers; |
| 1340 | |
| 1341 | auto pipelineId = driver->driverCtx()->pipelineId; |
| 1342 | |
| 1343 | if (self->isOutputPipeline(pipelineId)) { |
| 1344 | ++splitGroupState.numFinishedOutputDrivers; |
| 1345 | } |
| 1346 | |
| 1347 | // Release the driver, note that after this 'driver' is invalid. |
| 1348 | driverPtr = nullptr; |
| 1349 | self->driverClosedLocked(); |
| 1350 | |
| 1351 | allFinished = self->checkIfFinishedLocked(); |
| 1352 | |
| 1353 | // Check if a split group is finished. |
| 1354 | if (splitGroupState.numRunningDrivers == 0) { |
| 1355 | if (splitGroupId != kUngroupedGroupId) { |
| 1356 | --self->numRunningSplitGroups_; |
| 1357 | self->taskStats_.completedSplitGroups.emplace(splitGroupId); |
| 1358 | stateChangeNotifier.activate(std::move(self->stateChangePromises_)); |
| 1359 | splitGroupState.clear(); |
| 1360 | self->ensureSplitGroupsAreBeingProcessedLocked(); |
| 1361 | } else { |
| 1362 | splitGroupState.clear(); |
| 1363 | } |
| 1364 | } |
| 1365 | foundDriver = true; |
| 1366 | break; |
| 1367 | } |
| 1368 | |
| 1369 | if (self->numFinishedDrivers_ == self->numTotalDrivers_) { |
| 1370 | LOG(INFO) << "All drivers (" << self->numFinishedDrivers_ |
| 1371 | << ") finished for task " << self->taskId() |
| 1372 | << " after running for " |
| 1373 | << succinctMillis(self->timeSinceStartMsLocked()); |
| 1374 | } |
| 1375 | } |
| 1376 | stateChangeNotifier.notify(); |
| 1377 | |
| 1378 | if (!foundDriver) { |
| 1379 | LOG(WARNING) << "Trying to remove a Driver twice from its Task"; |
| 1380 | } |
| 1381 |
nothing calls this directly
no test coverage detected