MCPcopy Create free account
hub / github.com/bytedance/bolt / removeDriver

Method removeDriver

bolt/exec/Task.cpp:1324–1385  ·  view source on GitHub ↗

static

Source from the content-addressed store, hash-verified

1322
1323// static
1324void 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

Callers

nothing calls this directly

Calls 13

isOutputPipelineMethod · 0.95
driverClosedLockedMethod · 0.95
checkIfFinishedLockedMethod · 0.95
terminateMethod · 0.95
succinctMillisFunction · 0.85
activateMethod · 0.80
getMethod · 0.45
driverCtxMethod · 0.45
emplaceMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected