Skip to content

Commit

Permalink
make try_initialize_global_cpu_info thread safe
Browse files Browse the repository at this point in the history
  • Loading branch information
quink-black committed Sep 8, 2024
1 parent 0ca79c8 commit decbf28
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1932,15 +1932,10 @@ static void initialize_global_cpu_info()
#endif // defined __ANDROID__ || defined __linux__
}

static int g_cpu_info_initialized = 0;

static inline void try_initialize_global_cpu_info()
{
if (!g_cpu_info_initialized)
{
initialize_global_cpu_info();
g_cpu_info_initialized = 1;
}
static ncnn::OnceFlag flag = OnceFlagInit;
ncnn::CallOnce(flag, &initialize_global_cpu_info);
}

namespace ncnn {
Expand Down

0 comments on commit decbf28

Please sign in to comment.