Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't mix public and private data members (sonar).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 16 Feb 2022 11:25:00 +0000 (12:25 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 16 Feb 2022 12:37:25 +0000 (13:37 +0100)
src/kernel/activity/CommImpl.cpp
src/kernel/activity/CommImpl.hpp
src/kernel/actor/SimcallObserver.hpp

index 15b5cdf..98a5222 100644 (file)
@@ -267,7 +267,7 @@ void CommImpl::copy_data()
   copied_ = true;
 }
 
-ActivityImplPtr CommImpl::isend(actor::CommIsendSimcall* observer)
+ActivityImplPtr CommImpl::isend(const actor::CommIsendSimcall* observer)
 {
   auto* mbox = observer->get_mailbox();
   XBT_DEBUG("send from mailbox %p", mbox);
@@ -280,7 +280,7 @@ ActivityImplPtr CommImpl::isend(actor::CommIsendSimcall* observer)
    *
    * If it is not found then push our communication into the rendez-vous point */
   CommImplPtr other_comm =
-      mbox->find_matching_comm(CommImpl::Type::RECEIVE, observer->match_fun_, observer->get_payload(), this_comm,
+      mbox->find_matching_comm(CommImpl::Type::RECEIVE, observer->get_match_fun(), observer->get_payload(), this_comm,
                                /*done*/ false, /*remove_matching*/ true);
 
   if (not other_comm) {
@@ -304,7 +304,7 @@ ActivityImplPtr CommImpl::isend(actor::CommIsendSimcall* observer)
 
   if (observer->is_detached()) {
     other_comm->detach();
-    other_comm->clean_fun = observer->clean_fun_;
+    other_comm->clean_fun = observer->get_clean_fun();
   } else {
     other_comm->clean_fun = nullptr;
     observer->get_issuer()->activities_.emplace_back(other_comm);
@@ -318,8 +318,8 @@ ActivityImplPtr CommImpl::isend(actor::CommIsendSimcall* observer)
       .set_size(observer->get_payload_size())
       .set_rate(observer->get_rate());
 
-  other_comm->match_fun     = observer->match_fun_;
-  other_comm->copy_data_fun = observer->copy_data_fun_;
+  other_comm->match_fun     = observer->get_match_fun();
+  other_comm->copy_data_fun = observer->get_copy_data_fun();
 
   if (MC_is_active() || MC_record_replay_is_active())
     other_comm->set_state(simgrid::kernel::activity::State::RUNNING);
@@ -329,7 +329,7 @@ ActivityImplPtr CommImpl::isend(actor::CommIsendSimcall* observer)
   return (observer->is_detached() ? nullptr : other_comm);
 }
 
-ActivityImplPtr CommImpl::irecv(actor::CommIrecvSimcall* observer)
+ActivityImplPtr CommImpl::irecv(const actor::CommIrecvSimcall* observer)
 {
   CommImplPtr this_synchro(new CommImpl(CommImpl::Type::RECEIVE));
   auto* mbox = observer->get_mailbox();
@@ -340,7 +340,7 @@ ActivityImplPtr CommImpl::irecv(actor::CommIrecvSimcall* observer)
   if (mbox->is_permanent() && mbox->has_some_done_comm()) {
     XBT_DEBUG("We have a comm that has probably already been received, trying to match it, to skip the communication");
     // find a match in the list of already received comms
-    other_comm = mbox->find_matching_comm(CommImpl::Type::SEND, observer->match_fun_, observer->get_payload(),
+    other_comm = mbox->find_matching_comm(CommImpl::Type::SEND, observer->get_match_fun(), observer->get_payload(),
                                           this_synchro, /*done*/ true, /*remove_matching*/ true);
     // if not found, assume the receiver came first, register it to the mailbox in the classical way
     if (not other_comm) {
@@ -362,7 +362,7 @@ ActivityImplPtr CommImpl::irecv(actor::CommIrecvSimcall* observer)
      * ourself so that the other side also gets a chance of choosing if it wants to match with us.
      *
      * If it is not found then push our communication into the rendez-vous point */
-    other_comm = mbox->find_matching_comm(CommImpl::Type::SEND, observer->match_fun_, observer->get_payload(),
+    other_comm = mbox->find_matching_comm(CommImpl::Type::SEND, observer->get_match_fun(), observer->get_payload(),
                                           this_synchro, /*done*/ false, /*remove_matching*/ true);
 
     if (other_comm == nullptr) {
@@ -385,8 +385,8 @@ ActivityImplPtr CommImpl::irecv(actor::CommIrecvSimcall* observer)
   if (observer->get_rate() > -1.0 && (other_comm->get_rate() < 0.0 || observer->get_rate() < other_comm->get_rate()))
     other_comm->set_rate(observer->get_rate());
 
-  other_comm->match_fun     = observer->match_fun_;
-  other_comm->copy_data_fun = observer->copy_data_fun_;
+  other_comm->match_fun     = observer->get_match_fun();
+  other_comm->copy_data_fun = observer->get_copy_data_fun();
 
   if (MC_is_active() || MC_record_replay_is_active()) {
     other_comm->set_state(State::RUNNING);
index 3837b6b..7141785 100644 (file)
@@ -53,8 +53,8 @@ public:
   std::vector<s4u::Link*> get_traversed_links() const;
   void copy_data();
 
-  static ActivityImplPtr isend(actor::CommIsendSimcall* observer);
-  static ActivityImplPtr irecv(actor::CommIrecvSimcall* observer);
+  static ActivityImplPtr isend(const actor::CommIsendSimcall* observer);
+  static ActivityImplPtr irecv(const actor::CommIrecvSimcall* observer);
 
   bool test(actor::ActorImpl* issuer) override;
   void wait_for(actor::ActorImpl* issuer, double timeout) override;
index f75ae91..98cada2 100644 (file)
@@ -218,11 +218,11 @@ class CommIsendSimcall : public SimcallObserver {
   void* payload_;
   bool detached_;
 
-public:
   bool (*match_fun_)(void*, void*, activity::CommImpl*);
   void (*clean_fun_)(void*); // used to free the synchro in case of problem after a detached send
   void (*copy_data_fun_)(activity::CommImpl*, void*, size_t); // used to copy data if not default one
 
+public:
   CommIsendSimcall(ActorImpl* actor, activity::MailboxImpl* mbox, double payload_size, double rate,
                    unsigned char* src_buff, size_t src_buff_size, bool (*match_fun)(void*, void*, activity::CommImpl*),
                    void (*clean_fun)(void*), // used to free the synchro in case of problem after a detached send
@@ -250,6 +250,10 @@ public:
   size_t get_src_buff_size() const { return src_buff_size_; }
   void* get_payload() const { return payload_; }
   bool is_detached() const { return detached_; }
+
+  auto get_match_fun() const { return match_fun_; }
+  auto get_clean_fun() const { return clean_fun_; }
+  auto get_copy_data_fun() const { return copy_data_fun_; }
 };
 
 class CommIrecvSimcall : public SimcallObserver {
@@ -259,10 +263,10 @@ class CommIrecvSimcall : public SimcallObserver {
   void* payload_;
   double rate_;
 
-public:
   bool (*match_fun_)(void*, void*, activity::CommImpl*);
   void (*copy_data_fun_)(activity::CommImpl*, void*, size_t); // used to copy data if not default one
 
+public:
   CommIrecvSimcall(ActorImpl* actor, activity::MailboxImpl* mbox, unsigned char* dst_buff, size_t* dst_buff_size,
                    bool (*match_fun)(void*, void*, activity::CommImpl*),
                    void (*copy_data_fun)(activity::CommImpl*, void*, size_t), void* payload, double rate)
@@ -283,6 +287,9 @@ public:
   unsigned char* get_dst_buff() const { return dst_buff_; }
   size_t* get_dst_buff_size() const { return dst_buff_size_; }
   void* get_payload() const { return payload_; }
+
+  auto get_match_fun() const { return match_fun_; };
+  auto get_copy_data_fun() const { return copy_data_fun_; }
 };
 
 } // namespace actor