Replace std::hash namespace std specialization with custom task_ptr_hash#73
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: kgorking <781635+kgorking@users.noreply.github.com>
std::hash namespace std specialization with custom task_ptr_hash
|
@copilot The type |
Co-authored-by: kgorking <781635+kgorking@users.noreply.github.com>
Done in 3ac1e1f. Added |
There was a problem hiding this comment.
Pull request overview
This PR removes a std::hash specialization for task_ptr from namespace std and replaces it with a local task_ptr_hash + tasks_set alias, then updates task-graph code to use the new alias/types.
Changes:
- Introduces
task_ptr_hashandusing tasks_set = std::unordered_set<task_ptr, task_ptr_hash>intask_graph.h - Updates circular-dependency detection to use
tasks_setinstead ofstd::unordered_set<task_ptr> - Updates
task_name_mapto usetask_ptr_hashexplicitly forunordered_map<task_ptr, ...>
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| gbs/inc/task/task_graph.h | Removes std::hash specialization; adds task_ptr_hash, tasks_set, and applies hash to task_name_map. |
| gbs/src/task/task_graph.cpp | Switches visited set type to tasks_set in circular-dependency detection and dependency insertion. |
| gbs/src/cmd_build.cpp | Adds a global std::mutex declaration (currently unused). |
Comments suppressed due to low confidence (1)
gbs/src/task/task_graph.cpp:71
- The circular-dependency branch no longer exits early, so the dependency is still added after printing the error. This effectively allows cycles and will likely cause incorrect scheduling/termination behavior. Restore an early return (or otherwise abort/throw) when a circular path is detected so the edge is not inserted.
std::println(" '{}' (would create cycle)", parent_name);
}
child->deps.fetch_add(1, std::memory_order_relaxed);
parent->children.push_back(child);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
std::hash<std::shared_ptr<task>>specialization fromnamespace stdtask_ptr_hashstruct totask_graph.husing tasks_set = std::unordered_set<task_ptr, task_ptr_hash>aliastasks_setinstead of the verbose type💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.