Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Various sonar cleanups
[simgrid.git] / src / mc / transition / TransitionObjectAccess.cpp
index d16472e..f32e459 100644 (file)
@@ -15,14 +15,14 @@ ObjectAccessTransition::ObjectAccessTransition(aid_t issuer, int times_considere
 {
   short s;
   xbt_assert(stream >> s >> objaddr_ >> objname_ >> file_ >> line_);
-  type_ = static_cast<simgrid::mc::ObjectAccessType>(s);
+  access_type_ = static_cast<simgrid::mc::ObjectAccessType>(s);
 }
 std::string ObjectAccessTransition::to_string(bool verbose) const
 {
   std::string res;
-  if (type_ == ObjectAccessType::ENTER)
+  if (access_type_ == ObjectAccessType::ENTER)
     res = std::string("BeginObjectAccess(");
-  else if (type_ == ObjectAccessType::EXIT)
+  else if (access_type_ == ObjectAccessType::EXIT)
     res = std::string("EndObjectAccess(");
   else
     res = std::string("ObjectAccess(");
@@ -34,9 +34,23 @@ std::string ObjectAccessTransition::to_string(bool verbose) const
 }
 bool ObjectAccessTransition::depends(const Transition* o) const
 {
+  if (o->type_ < type_)
+    return o->depends(this);
+
+  // Actions executed by the same actor are always dependent
+  if (o->aid_ == aid_)
+    return true;
+
   if (const auto* other = dynamic_cast<const ObjectAccessTransition*>(o))
     return objaddr_ == other->objaddr_; // dependent only if it's an access to the same object
   return false;
 }
 
+bool ObjectAccessTransition::reversible_race(const Transition* other) const
+{
+  xbt_assert(type_ == Type::OBJECT_ACCESS, "Unexpected transition type %s", to_c_str(type_));
+
+  return true; // Object access is always enabled
+}
+
 } // namespace simgrid::mc