X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/29a3b2869c0075fc75e8ccc66fc1d9c4c8bf6a85..84402e8e2ee2a2d0bef25fdceb0a263ed8b471f6:/src/mc/sosp/ChunkedData.hpp?ds=sidebyside diff --git a/src/mc/sosp/ChunkedData.hpp b/src/mc/sosp/ChunkedData.hpp index c904a29f97..352214c301 100644 --- a/src/mc/sosp/ChunkedData.hpp +++ b/src/mc/sosp/ChunkedData.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2014-2018. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2014-2020. 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,13 +6,10 @@ #ifndef SIMGRID_MC_CHUNKED_DATA_HPP #define SIMGRID_MC_CHUNKED_DATA_HPP -#include -#include - -#include #include #include "src/mc/mc_forward.hpp" +#include "src/mc/remote/RemotePtr.hpp" #include "src/mc/sosp/PageStore.hpp" namespace simgrid { @@ -22,7 +19,7 @@ namespace mc { * * In order to save memory when taking memory snapshots, a given byte-string * is split in fixed-size chunks. Identical chunks (either from the same - * snapshot or more probably from different snpashots) share the same memory + * snapshot or more probably from different snapshots) share the same memory * storage. * * Thus a chunked is represented as a sequence of indices of each chunk. @@ -49,18 +46,20 @@ 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) : pagenos_(std::move(that.pagenos_)) { - that.store_ = nullptr; + std::swap(store_, that.store_); that.pagenos_.clear(); } ChunkedData& operator=(ChunkedData const& that) { - this->clear(); - store_ = that.store_; - pagenos_ = that.pagenos_; - for (std::size_t const& pageno : pagenos_) - store_->ref_page(pageno); + if (this != &that) { + this->clear(); + store_ = that.store_; + pagenos_ = that.pagenos_; + for (std::size_t const& pageno : pagenos_) + store_->ref_page(pageno); + } return *this; } ChunkedData& operator=(ChunkedData&& that) @@ -83,9 +82,9 @@ public: const std::size_t* pagenos() const { return pagenos_.data(); } /** Get a a pointer to a chunk */ - const void* page(std::size_t i) const { return store_->get_page(pagenos_[i]); } + 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