X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b0d07f67c6153ee2689bc22486c95becf4286493..9a4ec91cc24a9a54ff3a060cc2828ac54d0c0c26:/src/mc/sosp/ChunkedData.hpp diff --git a/src/mc/sosp/ChunkedData.hpp b/src/mc/sosp/ChunkedData.hpp index 2545954bc3..c4a706ff15 100644 --- a/src/mc/sosp/ChunkedData.hpp +++ b/src/mc/sosp/ChunkedData.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2014-2023. 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. */ @@ -12,8 +12,7 @@ #include "src/mc/remote/RemotePtr.hpp" #include "src/mc/sosp/PageStore.hpp" -namespace simgrid { -namespace mc { +namespace simgrid::mc { /** A byte-string represented as a sequence of chunks from a PageStore * @@ -46,9 +45,9 @@ public: for (std::size_t const& pageno : pagenos_) store_->ref_page(pageno); } - ChunkedData(ChunkedData&& that) : store_(that.store_), pagenos_(std::move(that.pagenos_)) + ChunkedData(ChunkedData&& that) noexcept : pagenos_(std::move(that.pagenos_)) { - that.store_ = nullptr; + std::swap(store_, that.store_); that.pagenos_.clear(); } ChunkedData& operator=(ChunkedData const& that) @@ -62,13 +61,15 @@ public: } return *this; } - ChunkedData& operator=(ChunkedData&& that) + ChunkedData& operator=(ChunkedData&& that) noexcept { - this->clear(); - store_ = that.store_; - that.store_ = nullptr; - pagenos_ = std::move(that.pagenos_); - that.pagenos_.clear(); + if (this != &that) { + this->clear(); + store_ = that.store_; + that.store_ = nullptr; + pagenos_ = std::move(that.pagenos_); + that.pagenos_.clear(); + } return *this; } @@ -81,13 +82,12 @@ public: /** Get a view of the chunk indices */ const std::size_t* pagenos() const { return pagenos_.data(); } - /** Get a a pointer to a chunk */ + /** Get a pointer to a chunk */ void* page(std::size_t i) const { return store_->get_page(pagenos_[i]); } - ChunkedData(PageStore& store, AddressSpace& as, RemotePtr addr, std::size_t page_count); + ChunkedData(PageStore& store, const AddressSpace& as, RemotePtr addr, std::size_t page_count); }; -} // namespace mc -} // namespace simgrid +} // namespace simgrid::mc #endif