Skip to content

Commit

Permalink
use std::atomic to protect concurrent access to the call_id_ static d…
Browse files Browse the repository at this point in the history
…ata member

Protect concurrent access to the Blif::call_id_ using an atomic data type: it is cheaper than a lock and for a machine word it is sufficent.

Resolves rmp in #5981.
  • Loading branch information
cc10512 committed Oct 21, 2024
1 parent c12d979 commit 15f1849
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/rmp/include/rmp/blif.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <stdio.h>
#include <unistd.h>

#include <atomic>
#include <map>
#include <set>
#include <string>
Expand Down Expand Up @@ -90,7 +91,7 @@ class Blif
std::string const1_cell_port_;
std::map<std::string, std::pair<float, float>> requireds_;
std::map<std::string, std::pair<float, float>> arrivals_;
static int call_id_;
static std::atomic<int> call_id_;
};

} // namespace rmp
2 changes: 1 addition & 1 deletion src/rmp/src/blif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ using utl::RMP;

namespace rmp {

int Blif::call_id_ = 0;
std::atomic<int> Blif::call_id_ = 0;

Blif::Blif(Logger* logger,
sta::dbSta* sta,
Expand Down

0 comments on commit 15f1849

Please sign in to comment.