Made the ForEachNode* functions in src/net.cpp more pragmatic and self documenting#55
Closed
JeremyRubin wants to merge 2 commits intotheuni:net-refactor13from
Closed
Made the ForEachNode* functions in src/net.cpp more pragmatic and self documenting#55JeremyRubin wants to merge 2 commits intotheuni:net-refactor13from
JeremyRubin wants to merge 2 commits intotheuni:net-refactor13from
Conversation
Owner
|
Thanks!
(On mobile, so bear with me)
On the encapsulation PR, kaz suggested dropping the std::function arg in
favor of a templated Callable in the header, to avoid incurring the stl
overhead for simple lambdas.
I think that's a good idea. Mind doing that at the same time here?
So It'd look something like (all in the header)
template <typename Callable>
void ForEachNode(Callable&& func)
{
LOCK..
for(nodes...){
func(node);
}
}
Also, if it would end up being simpler, you could implement them all terms
of a basic (private, possibly static) version with no locking.
With that, I believe it's also possible to eliminate ForEachNodeThen in
favor of passing in a callable object, with its "then" function simply
defined as its destructor. I'm not looking at the code now though, so i
could be wrong on that.
|
Author
|
Sure will code it up later today. I don't think I'll do the destructor version as that seems fragile. |
Owner
|
(I replied with this before, but seems it didn't go through. Disregard if this is a dupe) Thanks! Looks good. Nits:
|
…rather than a std::function to eliminate std::function overhead
55d060d to
2c96776
Compare
Author
|
Should be all set. |
Owner
|
Thanks, cherry-picked in. |
theuni
pushed a commit
that referenced
this pull request
Aug 22, 2025
efb8ea04e4 Merge bitcoin-core/crc32c-subtree#8: Sync to upstream 4a7a05c48d Merge remote-tracking branch 'google/main' into bitcoin-fork 21fc8ef304 Fix typo (bitcoin#59) 89f69843a1 Fix misspelled "Proccess" in comment 02e65f4fd3 Bump deps (#56) b9d6e825a1 Fix Windows CI build. (#54) bbbb93ab5d Switch CI to GitHub Actions (#55) d46cd17d70 Add clangd cache directory to .gitignore. git-subtree-dir: src/crc32c git-subtree-split: efb8ea04e4a5b6a18dc4bc1908fd1cb2dcefb585
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.