mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
tasks: change _children type
Keep task children in a map. It's a preparation for further changes.
This commit is contained in:
@@ -103,7 +103,8 @@ future<full_task_status> retrieve_status(const tasks::task_manager::foreign_task
|
||||
s.progress.completed = progress.completed;
|
||||
s.progress.total = progress.total;
|
||||
std::vector<std::string> ct{task->get_children().size()};
|
||||
boost::transform(task->get_children(), ct.begin(), [] (const auto& child) {
|
||||
boost::transform(task->get_children(), ct.begin(), [] (const auto& child_entry) {
|
||||
const auto& [child_id, child] = child_entry;
|
||||
return child->id().to_sstring();
|
||||
});
|
||||
s.children_ids = std::move(ct);
|
||||
@@ -231,7 +232,7 @@ void set_task_manager(http_context& ctx, routes& r, sharded<tasks::task_manager>
|
||||
while (!q.empty()) {
|
||||
auto& current = q.front();
|
||||
res.push_back(co_await retrieve_status(current));
|
||||
for (auto& child: current->get_children()) {
|
||||
for (const auto& [_, child] : current->get_children()) {
|
||||
q.push(co_await child.copy());
|
||||
}
|
||||
q.pop();
|
||||
|
||||
@@ -70,8 +70,8 @@ future<task_manager::task::progress> task_manager::task::impl::get_progress() co
|
||||
}
|
||||
|
||||
tasks::task_manager::task::progress progress{};
|
||||
for (auto& child: _children) {
|
||||
progress += co_await smp::submit_to(child.get_owner_shard(), [&child] {
|
||||
for (auto& [id, child]: _children) {
|
||||
progress += co_await smp::submit_to(child.get_owner_shard(), [&child = child] {
|
||||
return child->get_progress();
|
||||
});
|
||||
}
|
||||
@@ -92,8 +92,9 @@ future<> task_manager::task::impl::abort() noexcept {
|
||||
_as.request_abort();
|
||||
|
||||
std::vector<task_info> children_info{_children.size()};
|
||||
boost::transform(_children, children_info.begin(), [] (const auto& child) {
|
||||
return task_info{child->id(), child.get_owner_shard()};
|
||||
boost::transform(_children, children_info.begin(), [] (const auto& child_entry) {
|
||||
const auto& [child_id, child] = child_entry;
|
||||
return task_info{child_id, child.get_owner_shard()};
|
||||
});
|
||||
|
||||
co_await coroutine::parallel_for_each(children_info, [this] (auto info) {
|
||||
@@ -183,7 +184,8 @@ void task_manager::task::change_state(task_state state) noexcept {
|
||||
}
|
||||
|
||||
void task_manager::task::add_child(foreign_task_ptr&& child) {
|
||||
_impl->_children.push_back(std::move(child));
|
||||
auto inserted = _impl->_children.emplace(child->id(), std::move(child)).second;
|
||||
assert(inserted);
|
||||
}
|
||||
|
||||
void task_manager::task::start() {
|
||||
@@ -254,7 +256,7 @@ void task_manager::task::unregister_task() noexcept {
|
||||
_impl->_module->unregister_task(id());
|
||||
}
|
||||
|
||||
const task_manager::foreign_task_list& task_manager::task::get_children() const noexcept {
|
||||
const task_manager::foreign_task_map& task_manager::task::get_children() const noexcept {
|
||||
return _impl->_children;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
using task_ptr = lw_shared_ptr<task_manager::task>;
|
||||
using task_map = std::unordered_map<task_id, task_ptr>;
|
||||
using foreign_task_ptr = foreign_ptr<task_ptr>;
|
||||
using foreign_task_list = std::list<foreign_task_ptr>;
|
||||
using foreign_task_map = std::unordered_map<task_id, foreign_task_ptr>;
|
||||
using module_ptr = shared_ptr<module>;
|
||||
using modules = std::unordered_map<std::string, module_ptr>;
|
||||
private:
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
protected:
|
||||
status _status;
|
||||
task_id _parent_id;
|
||||
foreign_task_list _children;
|
||||
foreign_task_map _children;
|
||||
shared_promise<> _done;
|
||||
module_ptr _module;
|
||||
seastar::abort_source _as;
|
||||
@@ -167,7 +167,7 @@ public:
|
||||
future<> done() const noexcept;
|
||||
void register_task();
|
||||
void unregister_task() noexcept;
|
||||
const foreign_task_list& get_children() const noexcept;
|
||||
const foreign_task_map& get_children() const noexcept;
|
||||
bool is_complete() const noexcept;
|
||||
|
||||
friend class test_task;
|
||||
|
||||
Reference in New Issue
Block a user