A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Define macro XBT_ATTRIB_DEPRECATED_v340.
[simgrid.git]
/
include
/
simgrid
/
plugins
/
ProducerConsumer.hpp
diff --git
a/include/simgrid/plugins/ProducerConsumer.hpp
b/include/simgrid/plugins/ProducerConsumer.hpp
index 55dc6d6644d9c751c0fc4c24abfcf8cf8d2bc9d3..d4438e4ad72327e88dd519d861e2ab0da0229a70 100644
(file)
--- a/
include/simgrid/plugins/ProducerConsumer.hpp
+++ b/
include/simgrid/plugins/ProducerConsumer.hpp
@@
-22,8
+22,7
@@
XBT_LOG_EXTERNAL_CATEGORY(producer_consumer);
/** Stock implementation of a generic monitored queue to solve the producer-consumer problem */
/** Stock implementation of a generic monitored queue to solve the producer-consumer problem */
-namespace simgrid {
-namespace plugin {
+namespace simgrid::plugin {
template <typename T> class ProducerConsumer;
template <typename T> using ProducerConsumerPtr = boost::intrusive_ptr<ProducerConsumer<T>>;
template <typename T> class ProducerConsumer;
template <typename T> using ProducerConsumerPtr = boost::intrusive_ptr<ProducerConsumer<T>>;
@@
-104,7
+103,7
@@
public:
*/
ProducerConsumer* set_max_queue_size(unsigned int max_queue_size)
{
*/
ProducerConsumer* set_max_queue_size(unsigned int max_queue_size)
{
- const std::
lock_guard<s4u::Mutex>
lock(*mutex_);
+ const std::
scoped_lock
lock(*mutex_);
max_queue_size_ = max_queue_size;
return this;
}
max_queue_size_ = max_queue_size;
return this;
}
@@
-141,7
+140,7
@@
public:
*/
s4u::CommPtr put_async(T* data, size_t simulated_size_in_bytes)
{
*/
s4u::CommPtr put_async(T* data, size_t simulated_size_in_bytes)
{
- std::unique_lock
<s4u::Mutex>
lock(*mutex_);
+ std::unique_lock lock(*mutex_);
s4u::CommPtr comm = nullptr;
XBT_CVERB(producer_consumer, (size() < max_queue_size_) ? "can put" : "must wait");
s4u::CommPtr comm = nullptr;
XBT_CVERB(producer_consumer, (size() < max_queue_size_) ? "can put" : "must wait");
@@
-149,7
+148,6
@@
public:
can_put_->wait(lock);
if (tmode_ == TransferMode::MAILBOX) {
comm = mbox_->put_init(data, simulated_size_in_bytes)
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);
->start();
} else
queue_.push(data);
@@
-179,7
+177,7
@@
public:
*/
s4u::CommPtr get_async(T** data)
{
*/
s4u::CommPtr get_async(T** data)
{
- std::unique_lock
<s4u::Mutex>
lock(*mutex_);
+ std::unique_lock lock(*mutex_);
s4u::CommPtr comm = nullptr;
XBT_CVERB(producer_consumer, empty() ? "must wait" : "can get");
while (empty())
s4u::CommPtr comm = nullptr;
XBT_CVERB(producer_consumer, empty() ? "must wait" : "can get");
while (empty())
@@
-187,7
+185,6
@@
public:
if (tmode_ == TransferMode::MAILBOX)
comm = mbox_->get_init()
->set_dst_data(reinterpret_cast<void**>(data), sizeof(void*))
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();
->start();
else {
*data = queue_.front();
@@
-216,7
+213,6
@@
public:
}
};
}
};
-} // namespace plugin
-} // namespace simgrid
+} // namespace simgrid::plugin
#endif // SIMGRID_PLUGIN_PRODUCERCONSUMER_HPP
#endif // SIMGRID_PLUGIN_PRODUCERCONSUMER_HPP