1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-24 22:11:15 +02:00

Change to atomic<uint32_t>

This commit is contained in:
Farid Zakaria 2025-05-21 10:07:04 -07:00
parent 8fd15ac228
commit 6c85a90b87

View file

@ -625,7 +625,7 @@ std::pair<AutoCloseFD, Path> createTempFile(const Path & prefix)
Path makeTempPath(const Path & root, const Path & suffix)
{
// start the counter at a random value to minimize issues with preexisting temp paths
static std::atomic_uint_fast32_t counter(std::random_device{}());
static std::atomic<uint32_t> counter(std::random_device{}());
auto tmpRoot = canonPath(root.empty() ? defaultTempDir() : root, true);
return fmt("%1%/%2%-%3%-%4%", tmpRoot, suffix, getpid(), counter.fetch_add(1, std::memory_order_relaxed));
}