Commit 0b19393b authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

assume thread_local in Executor

Differential Revision: D27582476

fbshipit-source-id: 376fecda16de8a4836f9ba5196701a9045799ce7
parent eeaef4a2
...@@ -54,27 +54,17 @@ void Executor::keepAliveRelease() noexcept { ...@@ -54,27 +54,17 @@ void Executor::keepAliveRelease() noexcept {
// Base case of permitting with no termination to avoid nullptr tests // Base case of permitting with no termination to avoid nullptr tests
static ExecutorBlockingList emptyList{nullptr, {false, false, {}}}; static ExecutorBlockingList emptyList{nullptr, {false, false, {}}};
#if defined(FOLLY_TLS)
extern constexpr bool const executor_blocking_list_enabled = true;
thread_local ExecutorBlockingList* executor_blocking_list = &emptyList; thread_local ExecutorBlockingList* executor_blocking_list = &emptyList;
#else
extern constexpr bool const executor_blocking_list_enabled = false;
ExecutorBlockingList* executor_blocking_list = &emptyList;
#endif
Optional<ExecutorBlockingContext> getExecutorBlockingContext() noexcept { Optional<ExecutorBlockingContext> getExecutorBlockingContext() noexcept {
return // return //
!executor_blocking_list->curr.forbid ? none : // kIsMobile || !executor_blocking_list->curr.forbid ? none : //
make_optional(executor_blocking_list->curr); make_optional(executor_blocking_list->curr);
} }
ExecutorBlockingGuard::ExecutorBlockingGuard(PermitTag) noexcept ExecutorBlockingGuard::ExecutorBlockingGuard(PermitTag) noexcept {
: list_{*executor_blocking_list} { if (!kIsMobile) {
if (executor_blocking_list_enabled) { list_ = *executor_blocking_list;
list_.prev = executor_blocking_list; list_.prev = executor_blocking_list;
list_.curr.forbid = false; list_.curr.forbid = false;
list_.curr.name = {}; list_.curr.name = {};
...@@ -83,9 +73,9 @@ ExecutorBlockingGuard::ExecutorBlockingGuard(PermitTag) noexcept ...@@ -83,9 +73,9 @@ ExecutorBlockingGuard::ExecutorBlockingGuard(PermitTag) noexcept
} }
ExecutorBlockingGuard::ExecutorBlockingGuard( ExecutorBlockingGuard::ExecutorBlockingGuard(
TrackTag, StringPiece name) noexcept TrackTag, StringPiece name) noexcept {
: list_{*executor_blocking_list} { if (!kIsMobile) {
if (executor_blocking_list_enabled) { list_ = *executor_blocking_list;
list_.prev = executor_blocking_list; list_.prev = executor_blocking_list;
list_.curr.forbid = true; list_.curr.forbid = true;
list_.curr.name = name; list_.curr.name = name;
...@@ -94,9 +84,9 @@ ExecutorBlockingGuard::ExecutorBlockingGuard( ...@@ -94,9 +84,9 @@ ExecutorBlockingGuard::ExecutorBlockingGuard(
} }
ExecutorBlockingGuard::ExecutorBlockingGuard( ExecutorBlockingGuard::ExecutorBlockingGuard(
ProhibitTag, StringPiece name) noexcept ProhibitTag, StringPiece name) noexcept {
: list_{*executor_blocking_list} { if (!kIsMobile) {
if (executor_blocking_list_enabled) { list_ = *executor_blocking_list;
list_.prev = executor_blocking_list; list_.prev = executor_blocking_list;
list_.curr.forbid = true; list_.curr.forbid = true;
list_.curr.allowTerminationOnBlocking = true; list_.curr.allowTerminationOnBlocking = true;
...@@ -106,7 +96,7 @@ ExecutorBlockingGuard::ExecutorBlockingGuard( ...@@ -106,7 +96,7 @@ ExecutorBlockingGuard::ExecutorBlockingGuard(
} }
ExecutorBlockingGuard::~ExecutorBlockingGuard() { ExecutorBlockingGuard::~ExecutorBlockingGuard() {
if (executor_blocking_list_enabled) { if (!kIsMobile) {
if (executor_blocking_list != &list_) { if (executor_blocking_list != &list_) {
terminate_with<std::logic_error>("dtor mismatch"); terminate_with<std::logic_error>("dtor mismatch");
} }
......
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