Skip to content

Commit 326a6fa

Browse files
dmm-fbfacebook-github-bot
authored andcommitted
Use thread_local vs ThreadLocal in FilePoller
Summary: [Wangle] Use `thread_local` vs `ThreadLocal` in `FilePoller` to avoid something that looks like a DOF issue. (Note: this ignores all push blocking failures!) Reviewed By: yfeldblum Differential Revision: D19791123 fbshipit-source-id: f7443c2332faabf28956ee6e5850781e62c2011d
1 parent 9f582dc commit 326a6fa

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

wangle/util/FilePoller.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ folly::Singleton<PollerContext> contextSingleton([] {
5656
});
5757
}
5858

59-
folly::ThreadLocal<bool> FilePoller::ThreadProtector::polling_([] {
60-
return new bool(false);
61-
});
59+
bool* FilePoller::ThreadProtector::polling() {
60+
static thread_local bool sPolling{false};
61+
return &sPolling;
62+
}
63+
6264

6365
constexpr std::chrono::milliseconds FilePoller::kDefaultPollInterval;
6466

wangle/util/FilePoller.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,16 @@ class FilePoller {
160160
class ThreadProtector {
161161
public:
162162
ThreadProtector() {
163-
*polling_ = true;
163+
*polling() = true;
164164
}
165165
~ThreadProtector() {
166-
*polling_ = false;
166+
*polling() = false;
167167
}
168168
static bool inPollerThread() {
169-
return *polling_;
169+
return *polling();
170170
}
171-
static folly::ThreadLocal<bool> polling_;
171+
private:
172+
static bool* polling();
172173
};
173174
};
174175
}

0 commit comments

Comments
 (0)