Commit 73ccc053 authored by Andrii Grynenko's avatar Andrii Grynenko Committed by Facebook Github Bot

Remove unused fields from ThreadEntry

Differential Revision: D19001755

fbshipit-source-id: bda1a278017059e83c9a529aac7b429f074e42c1
parent cf08fcf6
...@@ -67,7 +67,6 @@ void ThreadEntryNode::eraseZero() { ...@@ -67,7 +67,6 @@ void ThreadEntryNode::eraseZero() {
StaticMetaBase::StaticMetaBase(ThreadEntry* (*threadEntry)(), bool strict) StaticMetaBase::StaticMetaBase(ThreadEntry* (*threadEntry)(), bool strict)
: nextId_(1), threadEntry_(threadEntry), strict_(strict) { : nextId_(1), threadEntry_(threadEntry), strict_(strict) {
head_.next = head_.prev = &head_;
int ret = pthread_key_create(&pthreadKey_, &onThreadExit); int ret = pthread_key_create(&pthreadKey_, &onThreadExit);
checkPosixError(ret, "pthread_key_create failed"); checkPosixError(ret, "pthread_key_create failed");
PthreadKeyUnregister::registerKey(pthreadKey_); PthreadKeyUnregister::registerKey(pthreadKey_);
...@@ -135,7 +134,6 @@ void StaticMetaBase::onThreadExit(void* ptr) { ...@@ -135,7 +134,6 @@ void StaticMetaBase::onThreadExit(void* ptr) {
std::lock_guard<std::mutex> g(meta.lock_); std::lock_guard<std::mutex> g(meta.lock_);
// mark it as removed // mark it as removed
threadEntry->removed_ = true; threadEntry->removed_ = true;
meta.erase(&(*threadEntry));
auto elementsCapacity = threadEntry->getElementsCapacity(); auto elementsCapacity = threadEntry->getElementsCapacity();
for (size_t i = 0u; i < elementsCapacity; ++i) { for (size_t i = 0u; i < elementsCapacity; ++i) {
threadEntry->elements[i].node.eraseZero(); threadEntry->elements[i].node.eraseZero();
...@@ -406,10 +404,6 @@ void StaticMetaBase::reserve(EntryID* id) { ...@@ -406,10 +404,6 @@ void StaticMetaBase::reserve(EntryID* id) {
{ {
std::lock_guard<std::mutex> g(meta.lock_); std::lock_guard<std::mutex> g(meta.lock_);
if (prevCapacity == 0) {
meta.push_back(threadEntry);
}
if (reallocated) { if (reallocated) {
/* /*
* Note: we need to hold the meta lock when copying data out of * Note: we need to hold the meta lock when copying data out of
......
...@@ -210,8 +210,6 @@ struct ThreadEntryList; ...@@ -210,8 +210,6 @@ struct ThreadEntryList;
struct ThreadEntry { struct ThreadEntry {
ElementWrapper* elements{nullptr}; ElementWrapper* elements{nullptr};
std::atomic<size_t> elementsCapacity{0}; std::atomic<size_t> elementsCapacity{0};
ThreadEntry* next{nullptr};
ThreadEntry* prev{nullptr};
ThreadEntryList* list{nullptr}; ThreadEntryList* list{nullptr};
ThreadEntry* listNext{nullptr}; ThreadEntry* listNext{nullptr};
StaticMetaBase* meta{nullptr}; StaticMetaBase* meta{nullptr};
...@@ -347,19 +345,6 @@ struct StaticMetaBase { ...@@ -347,19 +345,6 @@ struct StaticMetaBase {
StaticMetaBase(ThreadEntry* (*threadEntry)(), bool strict); StaticMetaBase(ThreadEntry* (*threadEntry)(), bool strict);
void push_back(ThreadEntry* t) {
t->next = &head_;
t->prev = head_.prev;
head_.prev->next = t;
head_.prev = t;
}
void erase(ThreadEntry* t) {
t->next->prev = t->prev;
t->prev->next = t->next;
t->next = t->prev = t;
}
FOLLY_EXPORT static ThreadEntryList* getThreadEntryList(); FOLLY_EXPORT static ThreadEntryList* getThreadEntryList();
static bool dying(); static bool dying();
...@@ -519,8 +504,6 @@ struct StaticMeta final : StaticMetaBase { ...@@ -519,8 +504,6 @@ struct StaticMeta final : StaticMetaBase {
static void onForkChild() { static void onForkChild() {
// only the current thread survives // only the current thread survives
auto& head = instance().head_; auto& head = instance().head_;
// init the head list
head.next = head.prev = &head;
// init the circular lists // init the circular lists
auto elementsCapacity = head.getElementsCapacity(); auto elementsCapacity = head.getElementsCapacity();
for (size_t i = 0u; i < elementsCapacity; ++i) { for (size_t i = 0u; i < elementsCapacity; ++i) {
...@@ -537,10 +520,6 @@ struct StaticMeta final : StaticMetaBase { ...@@ -537,10 +520,6 @@ struct StaticMeta final : StaticMetaBase {
} }
} }
// If this thread was in the list before the fork, add it back.
if (elementsCapacity != 0) {
instance().push_back(threadEntry);
}
instance().lock_.unlock(); instance().lock_.unlock();
} }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment