Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
use CRTP to factor refcounting across activity types
[simgrid.git] / src / s4u / s4u_Comm.cpp
index 0c28a0b..98965dc 100644 (file)
@@ -115,18 +115,18 @@ CommPtr Comm::set_tracing_category(const std::string& category)
 
 Comm* Comm::start()
 {
-  xbt_assert(state_ == State::INITED, "You cannot use %s() once your communication started (not implemented)",
+  xbt_assert(get_state() == State::INITED, "You cannot use %s() once your communication started (not implemented)",
              __FUNCTION__);
 
   if (src_buff_ != nullptr) { // Sender side
     on_sender_start(*Actor::self());
     pimpl_ = simcall_comm_isend(sender_, mailbox_->get_impl(), remains_, rate_, src_buff_, src_buff_size_, match_fun_,
-                                clean_fun_, copy_data_function_, user_data_, detached_);
+                                clean_fun_, copy_data_function_, get_user_data(), detached_);
   } else if (dst_buff_ != nullptr) { // Receiver side
     xbt_assert(not detached_, "Receive cannot be detached");
     on_receiver_start(*Actor::self());
     pimpl_ = simcall_comm_irecv(receiver_, mailbox_->get_impl(), dst_buff_, &dst_buff_size_, match_fun_,
-                                copy_data_function_, user_data_, rate_);
+                                copy_data_function_, get_user_data(), rate_);
 
   } else {
     xbt_die("Cannot start a communication before specifying whether we are the sender or the receiver");
@@ -157,12 +157,12 @@ Comm* Comm::wait_for(double timeout)
       if (src_buff_ != nullptr) {
         on_sender_start(*Actor::self());
         simcall_comm_send(sender_, mailbox_->get_impl(), remains_, rate_, src_buff_, src_buff_size_, match_fun_,
-                          copy_data_function_, user_data_, timeout);
+                          copy_data_function_, get_user_data(), timeout);
 
       } else { // Receiver
         on_receiver_start(*Actor::self());
         simcall_comm_recv(receiver_, mailbox_->get_impl(), dst_buff_, &dst_buff_size_, match_fun_, copy_data_function_,
-                          user_data_, timeout, rate_);
+                          get_user_data(), timeout, rate_);
       }
       state_ = State::FINISHED;
       break;
@@ -200,7 +200,7 @@ Comm* Comm::detach()
 
 Comm* Comm::cancel()
 {
-  simix::simcall([this] {
+  kernel::actor::simcall([this] {
     if (pimpl_)
       boost::static_pointer_cast<kernel::activity::CommImpl>(pimpl_)->cancel();
   });
@@ -235,16 +235,5 @@ Actor* Comm::get_sender()
   return sender_ ? sender_->ciface() : nullptr;
 }
 
-void intrusive_ptr_release(simgrid::s4u::Comm* c)
-{
-  if (c->refcount_.fetch_sub(1, std::memory_order_release) == 1) {
-    std::atomic_thread_fence(std::memory_order_acquire);
-    delete c;
-  }
-}
-void intrusive_ptr_add_ref(simgrid::s4u::Comm* c)
-{
-  c->refcount_.fetch_add(1, std::memory_order_relaxed);
-}
 } // namespace s4u
 } // namespace simgrid