Skip to content

Commit

Permalink
remove outdated branch when StaticMeta creates ThreadEntry
Browse files Browse the repository at this point in the history
Summary:
A newly-created `ThreadEntry` is not in the `ThreadEntryList` and cannot have its list-pointer set. No need to check.

No perf impact. Just makes the code a touch simpler.

Differential Revision: D59329930

fbshipit-source-id: a3e866d6fedfc9feb082c4aba6d18f042a44d36b
  • Loading branch information
yfeldblum authored and facebook-github-bot committed Jul 18, 2024
1 parent 3c48244 commit 069a50b
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions folly/detail/ThreadLocalDetail.h
Original file line number Diff line number Diff line change
Expand Up @@ -679,15 +679,10 @@ struct FOLLY_EXPORT StaticMeta final : StaticMetaBase {
if (!threadEntry) {
ThreadEntryList* threadEntryList = StaticMeta::getThreadEntryList();
threadEntry = new ThreadEntry();
// if the ThreadEntry already exists
// but pthread_getspecific returns NULL
// do not add the same entry twice to the list
// since this would create a loop in the list
if (!threadEntry->list) {
threadEntry->list = threadEntryList;
threadEntry->listNext = threadEntryList->head;
threadEntryList->head = threadEntry;
}

threadEntry->list = threadEntryList;
threadEntry->listNext = threadEntryList->head;
threadEntryList->head = threadEntry;

threadEntry->tid() = std::this_thread::get_id();
threadEntry->tid_os = folly::getOSThreadID();
Expand Down

0 comments on commit 069a50b

Please sign in to comment.