maint: Replace use of folly getCurrentThreadId with STL #1408
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.
Reference Issues/PRs
What does this implement or fix?
This is work to assist @jjerphan in removing use of folly in the ArcticDB code base.
The change here is to remove use of
folly::getCurrentThreadID()
inget_thread_id()
, replacing it with use ofstd::this_thread::get_id()
.Any other comments?
The folly implementation is much more complicated as there are different implementation for the 3 major OSes:
https://github.com/facebook/folly/blob/69a1b93df285457cd0799a6898e2e5390a09cd73/folly/system/ThreadId.cpp#L29-L37
The different implementations are not required as the STL C++11 solution should work on all OSes. I have kept the return type as
uint64_t
and hence am using the STLthread::hash
specialisation to convert the implementation-specificthread_id
to integer. It is possible for two thread IDs to have the same hash, but this has negligible mathematical probability, and also it doesn't matter of there are hash collisions as the only use ofget_thread_id
is in log messages.Checklist
Checklist for code changes...