-
Notifications
You must be signed in to change notification settings - Fork 18
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
Improve/fix named threads #131
Conversation
clang-tidy review says "All clean, LGTM! 👍" |
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.
I feel like it would make more sense to use the #if CELERITY_FEATURE_NAMED_THREADS
to define or stub out set_thread_name
, rather than doing it at every call site. This keeps the general code (where the call sites are) cleaner.
I wanted to not use a feature flag at all and so my first implementation had a similar idea of having a third stub implementation that would just print a warning that the feature was unsupported, however that obviously didn't work for the unit tests and so I added the feature flag. I like the idea of keeping the call-sites unchanged, so I'll move the feature flag inside the implementation. |
clang-tidy review says "All clean, LGTM! 👍" |
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.
Feature detection macros were originally intended for public APIs, like celerity::local_accessor
. This would be a new use for purely internal considerations.
We have a workaround for a similar problem when querying the affinity mask, which apple does not implement the way we want either. There, we exclude the translation unit affinity.unix.cc
and use a #ifdef __APPLE__
at the call site.
Without clearly preferring one over the other, these two cases should be handled in a similar manner.
I did not know feature detection macros were intended to be public, in that case if we decide to keep them for this use case we should clearly mark them as being As @PeterTh already pointed out it is cleaner to keep the call-sites unchanged, which I agree with. As for using Thoughts? |
There is precedence for |
clang-tidy review says "All clean, LGTM! 👍" |
1 similar comment
clang-tidy review says "All clean, LGTM! 👍" |
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.
LGTM!
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.
One minor remark, otherwise LGTM! Please squash before merging.
clang-tidy review says "All clean, LGTM! 👍" |
43b816f
to
a8433d8
Compare
clang-tidy review says "All clean, LGTM! 👍" |
This PR addresses two issues regarding named threads:
cy-main
, however, user code running in the main thread could spawn new threads, which would then inherit the same name, leading to more than onecy-main
thread. This behavior is probably more confusing than useful and this PR thus no longer gives the main thread a special name.pthread_setname_np
function used to set the name of threads has a different signature than on linux. This in and of itself is not an issue, however, the macOS version can only set the name of the calling thread, which is incompatible with the way celerity currently implements named threads. Therefore this PR adds a feature flagCELERITY_FEATURE_NAMED_THREADS
to disable the feature entirely on macOS.