+namespace simgrid::mc {
+
+std::string BarrierTransition::to_string(bool verbose) const
+{
+ return xbt::string_printf("%s(barrier: %u)", Transition::to_c_str(type_), bar_);
+}
+BarrierTransition::BarrierTransition(aid_t issuer, int times_considered, Type type, std::stringstream& stream)
+ : Transition(type, issuer, times_considered)
+{
+ xbt_assert(stream >> bar_);
+}
+bool BarrierTransition::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 BarrierTransition*>(o)) {
+ if (bar_ != other->bar_)
+ return false;
+
+ // LOCK indep LOCK: requests are not ordered in a barrier
+ if (type_ == Type::BARRIER_ASYNC_LOCK && other->type_ == Type::BARRIER_ASYNC_LOCK)
+ return false;
+
+ // WAIT indep WAIT: requests are not ordered
+ if (type_ == Type::BARRIER_WAIT && other->type_ == Type::BARRIER_WAIT)
+ return false;
+
+ return true; // LOCK/WAIT is dependent because lock may enable wait
+ }
+
+ return false; // barriers are INDEP with non-barrier transitions
+}
+