Skip to content

Commit

Permalink
[daemon] changed adapter from std::bind to lambda.
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeliao committed Jul 3, 2024
1 parent 985dff2 commit 5173700
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/daemon/daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2132,15 +2132,13 @@ try // clang-format on

std::function<grpc::Status(VirtualMachine&)> operation;
if (request->cancel_shutdown())
operation = std::bind(&Daemon::cancel_vm_shutdown, this, std::placeholders::_1);
operation = [this](const VirtualMachine& vm) { return this->cancel_vm_shutdown(vm); };
else if (request->force_stop())
{
auto adapted_switch_off_vm = [this](auto&& arg) -> grpc::Status { return this->switch_off_vm(arg); };
operation = adapted_switch_off_vm;
}
operation = [this](VirtualMachine& vm) { return this->switch_off_vm(vm); };

Check warning on line 2137 in src/daemon/daemon.cpp

View check run for this annotation

Codecov / codecov/patch

src/daemon/daemon.cpp#L2135-L2137

Added lines #L2135 - L2137 were not covered by tests
else
operation = std::bind(&Daemon::shutdown_vm, this, std::placeholders::_1,
std::chrono::minutes(request->time_minutes()));
operation = [this, delay_minutes = std::chrono::minutes(request->time_minutes())](VirtualMachine& vm) {
return this->shutdown_vm(vm, delay_minutes);
};

Check warning on line 2141 in src/daemon/daemon.cpp

View check run for this annotation

Codecov / codecov/patch

src/daemon/daemon.cpp#L2139-L2141

Added lines #L2139 - L2141 were not covered by tests

status = cmd_vms(instance_selection.operative_selection, operation);
}
Expand Down

0 comments on commit 5173700

Please sign in to comment.