Skip to content

Commit

Permalink
optimize batch hold/release (#394)
Browse files Browse the repository at this point in the history
Co-authored-by: NamelessOIer <[email protected]>
  • Loading branch information
RileyWen and NamelessOIer authored Dec 11, 2024
1 parent d85f41a commit 8312949
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/CraneCtld/CtldGrpcServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,14 @@ grpc::Status CraneCtldServiceImpl::ModifyTask(
}
} else if (request->attribute() == ModifyTaskRequest::Hold) {
int64_t secs = request->hold_seconds();
std::vector<std::pair<task_id_t, std::future<CraneErr>>> results;
results.reserve(request->task_ids().size());
for (auto task_id : request->task_ids()) {
err = g_task_scheduler->HoldReleaseTaskAsync(task_id, secs).get();
results.emplace_back(
task_id, g_task_scheduler->HoldReleaseTaskAsync(task_id, secs));
}
for (auto &[task_id, res] : results) {
err = res.get();
if (err == CraneErr::kOk) {
response->add_modified_tasks(task_id);
} else if (err == CraneErr::kNonExistent) {
Expand Down

0 comments on commit 8312949

Please sign in to comment.