-
Notifications
You must be signed in to change notification settings - Fork 37.7k
refactor: Use std::string for thread and index names #25971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
22eaf5b
to
4f7a2b6
Compare
Concept ACK |
1 similar comment
Concept ACK |
What about:
|
4f7a2b6
to
a6927e8
Compare
Force pushed to address review comments about simplifying the |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Concept ACK. |
a6927e8
to
4b1a0bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Force pushed to address review feedback regarding:
util::TraceThread()
to take astd::string
copy and avoid potential issues with lifetime introduced by the threading, also updatedutil::ThreadRename()
to take a const lvalue ref to avoid copying twice- remove unused includes leftover from earlier versions
4b1a0bb
to
296b831
Compare
Force pushed to partly reverse the previous force push based on sipa's suggestion, again using a My apologies to reviewers for the back and forth. |
296b831
to
e5d9c6f
Compare
Force pushed to rebase on latest master to fix failing CI (wallet_groups.py) - no other changes. |
My preference would still be to use review ACK e5d9c6f 🎯 Show signatureSignature:
|
e5d9c6f
to
200d84d
Compare
Force pushed to fix merge conflict from #24513 that renamed
I'm not opposed to it, but as I don't have a strong view on it, we've already had some back-and-forth and the current implementation doesn't introduce new assumptions there I'd prefer to keep that for a follow-up (which I won't do). |
re-ACK 200d84d only change is rebase 🚼 Show signatureSignature:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 200d84d
Since it is now a string_view instead of a const char*, update the name to reflect that the variable is no longer a "Pointer to String, Zero-terminated" (psz). -BEGIN VERIFY SCRIPT- sed -i s/pszThread/thread_name/ $(git grep -l pszThread src) -END VERIFY SCRIPT-
review ACK 26cf9ea only change is new scripted-diff 😀 Show signatureSignature:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 26cf9ea, I have reviewed the code and it looks OK.
@@ -10,10 +10,12 @@ | |||
|
|||
#include <exception> | |||
#include <functional> | |||
#include <string> | |||
#include <utility> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Why #include <utility>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::move (Edit: Oh yeah. That one isn't used.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ git grep move -- src//util/thread.cpp | wc -l
0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iwyu:
util/thread.h should add these lines:
#include <string_view> // for string_view
util/thread.h should remove these lines:
- #include <string> // lines 9-9
The full include-list for util/thread.h:
#include <functional> // for function
#include <string_view> // for string_view
---
util/thread.cpp should add these lines:
util/thread.cpp should remove these lines:
- #include <utility> // lines 14-14
The full include-list for util/thread.cpp:
#include <util/thread.h>
#include <logging.h> // for LogPrintf_, LogPrintf
#include <util/system.h> // for PrintExceptionContinue
#include <util/threadnames.h> // for ThreadRename
#include <exception> // for exception
#include <functional> // for function
#include <string> // for allocator, string
---
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reACK 26cf9ea
As a follow-up to #25967 (comment), this PR changes the return type of
BaseIndex::GetName()
toconst std::string&
instead ofconst char*
. The first commit is not essential for this change, but since the code is touched and index names are commonly used to specify thread names, I've made the same update there.No behaviour change, just refactoring to further phase out C-style strings.
Note:
util::ThreadRename()
used to take an rvalue ref, but since it then passes this toSetInternalName()
by value, I don't think there's any benefit to having both an rvalue and lvalue ref function so I just changed it into lvalue ref. Not 100% sure I'm missing something?