Files
pytorch/c10/util/ParallelGuard.cpp
cyy 3907f36808 Turn some variables and functions into static (#136847)
Re-check some files and mark variables and functions into static and fix other warnings.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/136847
Approved by: https://github.com/ezyang
2024-10-29 17:01:56 +00:00

20 lines
363 B
C++

#include <c10/util/ParallelGuard.h>
namespace c10 {
thread_local static bool in_at_parallel = false;
bool ParallelGuard::is_enabled() {
return in_at_parallel;
}
ParallelGuard::ParallelGuard(bool state) : previous_state_(is_enabled()) {
in_at_parallel = state;
}
ParallelGuard::~ParallelGuard() {
in_at_parallel = previous_state_;
}
} // namespace c10