void growSegment() {
// We first need to unmap it before calling grow().
const size_t prev_size = base_sgmt_->get_size();
+ base_sgmt_->flush();
base_sgmt_.reset();
const size_t new_size = prev_size * 2;
}
MemorySegmentMapped::~MemorySegmentMapped() {
+ if (impl_->base_sgmt_ && !impl_->read_only_) {
+ impl_->base_sgmt_->flush(); // note: this is exception free
+ }
delete impl_;
}
MemorySegmentMapped(const std::string& filename, bool create,
size_t initial_size = INITIAL_SIZE);
- /// \brief Destructor
+ /// \brief Destructor.
+ ///
+ /// If the object was constructed in the read-write mode and the underlying
+ /// memory segment wasn't broken due to an exceptional event, the
+ /// destructor ensures the content of the mapped memory is written back to
+ /// the corresponding file.
virtual ~MemorySegmentMapped();
/// \brief Allocate/acquire a segment of memory.