Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Inline s4u::Comm::copy_pointer_callback which is the default callback.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 8 Mar 2023 15:36:13 +0000 (16:36 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 8 Mar 2023 15:37:45 +0000 (16:37 +0100)
include/simgrid/plugins/ProducerConsumer.hpp
src/kernel/activity/CommImpl.cpp

index 55dc6d6..b6af5a4 100644 (file)
@@ -149,7 +149,6 @@ public:
       can_put_->wait(lock);
     if (tmode_ == TransferMode::MAILBOX) {
       comm = mbox_->put_init(data, simulated_size_in_bytes)
-                 ->set_copy_data_callback(s4u::Comm::copy_pointer_callback)
                  ->start();
     } else
       queue_.push(data);
@@ -187,7 +186,6 @@ public:
     if (tmode_ == TransferMode::MAILBOX)
       comm = mbox_->get_init()
                  ->set_dst_data(reinterpret_cast<void**>(data), sizeof(void*))
-                 ->set_copy_data_callback(s4u::Comm::copy_pointer_callback)
                  ->start();
     else {
       *data = queue_.front();
index 4c1deb7..44ec50b 100644 (file)
@@ -23,7 +23,11 @@ namespace simgrid::kernel::activity {
 xbt::signal<void(CommImpl const&)> CommImpl::on_start;
 xbt::signal<void(CommImpl const&)> CommImpl::on_completion;
 
-std::function<void(CommImpl*, void*, size_t)> CommImpl::copy_data_callback_ = &s4u::Comm::copy_pointer_callback;
+std::function<void(CommImpl*, void*, size_t)> CommImpl::copy_data_callback_ = [](kernel::activity::CommImpl* comm,
+                                                                                 void* buff, size_t buff_size) {
+  xbt_assert((buff_size == sizeof(void*)), "Cannot copy %zu bytes: must be sizeof(void*)", buff_size);
+  *(void**)(comm->dst_buff_) = buff;
+};
 
 void CommImpl::set_copy_data_callback(const std::function<void(CommImpl*, void*, size_t)>& callback)
 {