Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove redundant cast (Sonar).
[simgrid.git] / src / kernel / actor / SimcallObserver.cpp
index 80d8326..88428f1 100644 (file)
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_observer, mc, "Logging specific to MC simcall observation");
 
-namespace simgrid {
-namespace kernel {
-namespace actor {
+namespace simgrid::kernel::actor {
 
-void SimcallObserver::serialize(std::stringstream& stream) const
-{
-  stream << (short)mc::Transition::Type::UNKNOWN;
-}
-bool SimcallObserver::depends(SimcallObserver* other)
-{
-  THROW_UNIMPLEMENTED;
-}
-/* Random is only dependent when issued by the same actor (ie, always independent) */
-bool RandomSimcall::depends(SimcallObserver* other)
-{
-  return get_issuer() == other->get_issuer();
-}
 void RandomSimcall::serialize(std::stringstream& stream) const
 {
   stream << (short)mc::Transition::Type::RANDOM << ' ';
@@ -43,31 +28,35 @@ void RandomSimcall::prepare(int times_considered)
   XBT_DEBUG("MC_RANDOM(%d, %d) will return %d after %d times", min_, max_, next_value_, times_considered);
 }
 
-int RandomSimcall::get_max_consider()
+int RandomSimcall::get_max_consider() const
 {
   return max_ - min_ + 1;
 }
 
 bool ConditionWaitSimcall::is_enabled()
 {
-  static bool warned = false;
-  if (not warned) {
+  if (static bool warned = false; not warned) {
     XBT_INFO("Using condition variables in model-checked code is still experimental. Use at your own risk");
     warned = true;
   }
   return true;
 }
-
-bool SemAcquireSimcall::is_enabled()
+void ConditionWaitSimcall::serialize(std::stringstream& stream) const
 {
-  static bool warned = false;
-  if (not warned) {
-    XBT_INFO("Using semaphore in model-checked code is still experimental. Use at your own risk");
-    warned = true;
-  }
-  return true;
+  THROW_UNIMPLEMENTED;
 }
 
-} // namespace actor
-} // namespace kernel
-} // namespace simgrid
+ActorJoinSimcall::ActorJoinSimcall(ActorImpl* actor, ActorImpl* other, double timeout)
+    : SimcallObserver(actor), other_(s4u::ActorPtr(other->get_iface())), timeout_(timeout)
+{
+}
+bool ActorJoinSimcall::is_enabled()
+{
+  return other_->get_impl()->wannadie();
+}
+void ActorJoinSimcall::serialize(std::stringstream& stream) const
+{
+  stream << (short)mc::Transition::Type::ACTOR_JOIN << ' ';
+  stream << other_->get_pid() << ' ' << (timeout_ > 0);
+}
+} // namespace simgrid::kernel::actor