Skip to content

Replace std::hash namespace std specialization with custom task_ptr_hash#73

Merged
kgorking merged 23 commits into
masterfrom
copilot/sub-pr-72
Mar 11, 2026
Merged

Replace std::hash namespace std specialization with custom task_ptr_hash#73
kgorking merged 23 commits into
masterfrom
copilot/sub-pr-72

Conversation

Copilot AI commented Mar 11, 2026

Copy link
Copy Markdown
Contributor
  • Remove std::hash<std::shared_ptr<task>> specialization from namespace std
  • Add custom task_ptr_hash struct to task_graph.h
  • Add using tasks_set = std::unordered_set<task_ptr, task_ptr_hash> alias
  • Update all usages to use tasks_set instead 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.

Co-authored-by: kgorking <781635+kgorking@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on module partitions and filtering os-specific files Replace std::hash namespace std specialization with custom task_ptr_hash Mar 11, 2026
@kgorking

Copy link
Copy Markdown
Owner

@copilot The type std::unordered_set<task_ptr, task_ptr_hash> has gotten long. Add a 'using tasks_set = ...' and use that instead.

Co-authored-by: kgorking <781635+kgorking@users.noreply.github.com>

Copilot AI commented Mar 11, 2026

Copy link
Copy Markdown
Contributor Author

@copilot The type std::unordered_set<task_ptr, task_ptr_hash> has gotten long. Add a 'using tasks_set = ...' and use that instead.

Done in 3ac1e1f. Added using tasks_set = std::unordered_set<task_ptr, task_ptr_hash>; after the hasher struct, and replaced all occurrences of the verbose type in both the header and source file.

Base automatically changed from Support-for-module-partitions to master March 11, 2026 06:14
@kgorking kgorking marked this pull request as ready for review March 11, 2026 06:21
Copilot AI review requested due to automatic review settings March 11, 2026 06:21
@kgorking kgorking merged commit 99f2908 into master Mar 11, 2026
8 checks passed
@kgorking kgorking deleted the copilot/sub-pr-72 branch March 11, 2026 06:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_hash and using tasks_set = std::unordered_set<task_ptr, task_ptr_hash> in task_graph.h
  • Updates circular-dependency detection to use tasks_set instead of std::unordered_set<task_ptr>
  • Updates task_name_map to use task_ptr_hash explicitly for unordered_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.

Comment thread gbs/src/cmd_build.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants