| 40 | } |
| 41 | |
| 42 | std::future<utils::TaskRescheduleInfo> SchedulingAgent::enableControllerService(std::shared_ptr<core::controller::ControllerServiceNode> &serviceNode) { |
| 43 | logger_->log_info("Enabling CSN in SchedulingAgent %s", serviceNode->getName()); |
| 44 | // reference the enable function from serviceNode |
| 45 | std::function<utils::TaskRescheduleInfo()> f_ex = [serviceNode] { |
| 46 | serviceNode->enable(); |
| 47 | return utils::TaskRescheduleInfo::Done(); |
| 48 | }; |
| 49 | |
| 50 | // only need to run this once. |
| 51 | auto monitor = utils::make_unique<utils::ComplexMonitor>(); |
| 52 | utils::Worker<utils::TaskRescheduleInfo> functor(f_ex, serviceNode->getUUIDStr(), std::move(monitor)); |
| 53 | // move the functor into the thread pool. While a future is returned |
| 54 | // we aren't terribly concerned with the result. |
| 55 | std::future<utils::TaskRescheduleInfo> future; |
| 56 | thread_pool_.execute(std::move(functor), future); |
| 57 | if (future.valid()) |
| 58 | future.wait(); |
| 59 | return future; |
| 60 | } |
| 61 | |
| 62 | std::future<utils::TaskRescheduleInfo> SchedulingAgent::disableControllerService(std::shared_ptr<core::controller::ControllerServiceNode> &serviceNode) { |
| 63 | logger_->log_info("Disabling CSN in SchedulingAgent %s", serviceNode->getName()); |