X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/23a215b2525a9b93dddb07f33c63ec26c467e98f..c3aba869402fd6e57bd6c70dde801e6995037d99:/include/simgrid/plugins/ProducerConsumer.hpp diff --git a/include/simgrid/plugins/ProducerConsumer.hpp b/include/simgrid/plugins/ProducerConsumer.hpp index 5c76d27221..66381ca638 100644 --- a/include/simgrid/plugins/ProducerConsumer.hpp +++ b/include/simgrid/plugins/ProducerConsumer.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2021. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2021-2022. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -6,6 +6,7 @@ #ifndef SIMGRID_PLUGIN_PRODUCERCONSUMER_HPP #define SIMGRID_PLUGIN_PRODUCERCONSUMER_HPP +#include #include #include #include @@ -17,7 +18,7 @@ #include #include -XBT_LOG_NEW_CATEGORY(producer_consumer, "Producer-Consumer plugin logging category"); +XBT_LOG_EXTERNAL_CATEGORY(producer_consumer); /** Stock implementation of a generic monitored queue to solve the producer-consumer problem */ @@ -27,7 +28,7 @@ namespace plugin { template class ProducerConsumer; template using ProducerConsumerPtr = boost::intrusive_ptr>; -static unsigned long pc_id = 0; +XBT_PUBLIC_DATA unsigned long pc_id; template class ProducerConsumer { public: @@ -145,7 +146,9 @@ public: while (size() >= max_queue_size_) can_put_->wait(lock); if (tmode_ == TransferMode::MAILBOX) { - comm = mbox_->put_async(data, simulated_size_in_bytes); + comm = mbox_->put_init(data, simulated_size_in_bytes) + ->set_copy_data_callback(s4u::Comm::copy_pointer_callback) + ->start(); } else queue_.push(data); can_get_->notify_all(); @@ -180,7 +183,10 @@ public: while (empty()) can_get_->wait(lock); if (tmode_ == TransferMode::MAILBOX) - comm = mbox_->get_async(data); + comm = mbox_->get_init() + ->set_dst_data(reinterpret_cast(data), sizeof(void*)) + ->set_copy_data_callback(s4u::Comm::copy_pointer_callback) + ->start(); else { *data = queue_.front(); queue_.pop();