• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <c10/util/ParallelGuard.h>
2 
3 namespace c10 {
4 
5 thread_local bool in_at_parallel = false;
6 
is_enabled()7 bool ParallelGuard::is_enabled() {
8   return in_at_parallel;
9 }
10 
ParallelGuard(bool state)11 ParallelGuard::ParallelGuard(bool state) : previous_state_(is_enabled()) {
12   in_at_parallel = state;
13 }
14 
~ParallelGuard()15 ParallelGuard::~ParallelGuard() {
16   in_at_parallel = previous_state_;
17 }
18 
19 } // namespace c10
20