xref: /aosp_15_r20/external/executorch/extension/threadpool/threadpool_guard.cpp (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1*523fa7a6SAndroid Build Coastguard Worker /*
2*523fa7a6SAndroid Build Coastguard Worker  * Copyright (c) Meta Platforms, Inc. and affiliates.
3*523fa7a6SAndroid Build Coastguard Worker  * All rights reserved.
4*523fa7a6SAndroid Build Coastguard Worker  *
5*523fa7a6SAndroid Build Coastguard Worker  * This source code is licensed under the BSD-style license found in the
6*523fa7a6SAndroid Build Coastguard Worker  * LICENSE file in the root directory of this source tree.
7*523fa7a6SAndroid Build Coastguard Worker  */
8*523fa7a6SAndroid Build Coastguard Worker 
9*523fa7a6SAndroid Build Coastguard Worker #include <executorch/extension/threadpool/threadpool_guard.h>
10*523fa7a6SAndroid Build Coastguard Worker 
11*523fa7a6SAndroid Build Coastguard Worker namespace executorch::extension::threadpool {
12*523fa7a6SAndroid Build Coastguard Worker 
13*523fa7a6SAndroid Build Coastguard Worker thread_local bool NoThreadPoolGuard_enabled = false;
14*523fa7a6SAndroid Build Coastguard Worker 
is_enabled()15*523fa7a6SAndroid Build Coastguard Worker bool NoThreadPoolGuard::is_enabled() {
16*523fa7a6SAndroid Build Coastguard Worker   return NoThreadPoolGuard_enabled;
17*523fa7a6SAndroid Build Coastguard Worker }
18*523fa7a6SAndroid Build Coastguard Worker 
set_enabled(bool enabled)19*523fa7a6SAndroid Build Coastguard Worker void NoThreadPoolGuard::set_enabled(bool enabled) {
20*523fa7a6SAndroid Build Coastguard Worker   NoThreadPoolGuard_enabled = enabled;
21*523fa7a6SAndroid Build Coastguard Worker }
22*523fa7a6SAndroid Build Coastguard Worker 
23*523fa7a6SAndroid Build Coastguard Worker } // namespace executorch::extension::threadpool
24