Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Define CommImpl::type_ at construction.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 4 Feb 2021 21:47:53 +0000 (22:47 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 4 Feb 2021 21:47:53 +0000 (22:47 +0100)
src/kernel/activity/CommImpl.cpp
src/kernel/activity/CommImpl.hpp
src/kernel/activity/MailboxImpl.cpp

index 8f36c29..c57f0a7 100644 (file)
@@ -41,8 +41,8 @@ XBT_PRIVATE simgrid::kernel::activity::ActivityImplPtr simcall_HANDLER_comm_isen
   XBT_DEBUG("send from mailbox %p", mbox);
 
   /* Prepare a synchro describing us, so that it gets passed to the user-provided filter of other side */
-  simgrid::kernel::activity::CommImplPtr this_comm(new simgrid::kernel::activity::CommImpl());
-  this_comm->set_type(simgrid::kernel::activity::CommImpl::Type::SEND);
+  simgrid::kernel::activity::CommImplPtr this_comm(
+      new simgrid::kernel::activity::CommImpl(simgrid::kernel::activity::CommImpl::Type::SEND));
 
   /* Look for communication synchro matching our needs. We also provide a description of
    * ourself so that the other side also gets a chance of choosing if it wants to match with us.
@@ -114,8 +114,8 @@ simcall_HANDLER_comm_irecv(smx_simcall_t /*simcall*/, smx_actor_t receiver, smx_
                            void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data,
                            double rate)
 {
-  simgrid::kernel::activity::CommImplPtr this_synchro(new simgrid::kernel::activity::CommImpl());
-  this_synchro->set_type(simgrid::kernel::activity::CommImpl::Type::RECEIVE);
+  simgrid::kernel::activity::CommImplPtr this_synchro(
+      new simgrid::kernel::activity::CommImpl(simgrid::kernel::activity::CommImpl::Type::RECEIVE));
   XBT_DEBUG("recv from mbox %p. this_synchro=%p", mbox, this_synchro.get());
 
   simgrid::kernel::activity::CommImplPtr other_comm;
@@ -408,7 +408,8 @@ CommImpl& CommImpl::detach()
   return *this;
 }
 
-CommImpl::CommImpl(s4u::Host* from, s4u::Host* to, double bytes) : size_(bytes), detached_(true), from_(from), to_(to)
+CommImpl::CommImpl(s4u::Host* from, s4u::Host* to, double bytes)
+    : size_(bytes), detached_(true), type_(Type::SEND), from_(from), to_(to)
 {
   state_ = State::READY;
 }
index 2ed9b72..195209d 100644 (file)
@@ -26,11 +26,11 @@ class XBT_PUBLIC CommImpl : public ActivityImpl_T<CommImpl> {
   MailboxImpl* mbox_ = nullptr; /* Rendez-vous where the comm is queued */
 
 public:
-  CommImpl() = default;
-  CommImpl(s4u::Host* from, s4u::Host* to, double bytes);
-
   enum class Type { SEND = 0, RECEIVE, READY, DONE };
 
+  CommImpl(Type type) : type_(type) {}
+  CommImpl(s4u::Host* from, s4u::Host* to, double bytes);
+
   CommImpl& set_type(CommImpl::Type type);
   CommImpl& set_size(double size);
   CommImpl& set_src_buff(unsigned char* buff, size_t size);
index c84746a..f812f45 100644 (file)
@@ -92,12 +92,10 @@ CommImplPtr MailboxImpl::iprobe(int type, bool (*match_fun)(void*, void*, CommIm
   CommImplPtr this_comm;
   CommImpl::Type smx_type;
   if (type == 1) {
-    this_comm = CommImplPtr(new CommImpl());
-    this_comm->set_type(CommImpl::Type::SEND);
+    this_comm = CommImplPtr(new CommImpl(CommImpl::Type::SEND));
     smx_type  = CommImpl::Type::RECEIVE;
   } else {
-    this_comm = CommImplPtr(new CommImpl());
-    this_comm->set_type(CommImpl::Type::RECEIVE);
+    this_comm = CommImplPtr(new CommImpl(CommImpl::Type::RECEIVE));
     smx_type  = CommImpl::Type::SEND;
   }
   CommImplPtr other_comm = nullptr;