Skip to content

Commit

Permalink
Merge pull request #126 from eseiler/fix/race
Browse files Browse the repository at this point in the history
[FIX] Concurrent read/write
  • Loading branch information
eseiler authored Jun 24, 2024
2 parents f344f95 + a74cfc1 commit 7e07a14
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions include/sdsl/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define INCLUDED_SDSL_UTIL

#include <algorithm>
#include <atomic>
#include <cassert>
#include <chrono>
#include <cstdlib>
Expand Down Expand Up @@ -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<uint64_t> id{0u};
return id++;
}

//! Get the process id of the current process
Expand Down

0 comments on commit 7e07a14

Please sign in to comment.