Remove static initializers (#2059)

* Remove static initializers in device.cpp, load.cpp, pocketfft.h

* Remove static initializer InTracing::trace_stack

* Remove static initializer of CompilerCache cache

* Revert changes in pocketfft.h

* Remove duplicate private section of thread_pool()
This commit is contained in:
hdeng-apple
2025-04-24 21:14:49 +08:00
committed by GitHub
parent fbc89e3ced
commit 86984cad68
6 changed files with 37 additions and 22 deletions

View File

@@ -335,7 +335,10 @@ ThreadPool& thread_pool() {
return pool_;
}
ThreadPool ParallelFileReader::thread_pool_{4};
ThreadPool& ParallelFileReader::thread_pool() {
static ThreadPool thread_pool{4};
return thread_pool;
}
void ParallelFileReader::read(char* data, size_t n) {
while (n != 0) {
@@ -371,7 +374,8 @@ void ParallelFileReader::read(char* data, size_t n, size_t offset) {
break;
} else {
size_t m = batch_size_;
futs.emplace_back(thread_pool_.enqueue(readfn, offset, m, data));
futs.emplace_back(
ParallelFileReader::thread_pool().enqueue(readfn, offset, m, data));
data += m;
n -= m;
offset += m;