From a74cfc1e238fbf9621ac20309008ffe5b671cbef Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Mon, 24 Jun 2024 11:00:44 +0200 Subject: [PATCH] [FIX] Concurrent read/write --- include/sdsl/util.hpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/include/sdsl/util.hpp b/include/sdsl/util.hpp index c47d3f88..16496d23 100644 --- a/include/sdsl/util.hpp +++ b/include/sdsl/util.hpp @@ -9,6 +9,7 @@ #define INCLUDED_SDSL_UTIL #include +#include #include #include #include @@ -345,15 +346,10 @@ inline char * str_from_errno() #endif } -struct _id_helper_struct +inline uint64_t _id_helper() { - uint64_t id = 0; -}; - -extern inline uint64_t _id_helper() -{ - static _id_helper_struct data; - return data.id++; + static std::atomic id{0u}; + return id++; } //! Get the process id of the current process