Make DestructorCheck::Safety no-copy, no-move
[folly.git] / folly / MemoryMapping.h
index 51b5e8904824e0daa1838130314357ce86e99b82..14ce382da7938c510f09073afdfb12a6c255eae2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * limitations under the License.
  */
 
-#ifndef FOLLY_MEMORYMAPPING_H_
-#define FOLLY_MEMORYMAPPING_H_
+#pragma once
 
-#include "folly/FBString.h"
-#include "folly/File.h"
-#include "folly/Range.h"
+#include <folly/File.h>
+#include <folly/Range.h>
 #include <glog/logging.h>
 #include <boost/noncopyable.hpp>
 
@@ -53,7 +51,7 @@ class MemoryMapping : boost::noncopyable {
    * likely become inaccessible) when the MemoryMapping object is destroyed.
    */
   struct Options {
-    Options() { }
+    Options() {}
 
     // Convenience methods; return *this for chaining.
     Options& setPageSize(off_t v) { pageSize = v; return *this; }
@@ -70,8 +68,8 @@ class MemoryMapping : boost::noncopyable {
 
     // If shared (default), the memory mapping is shared with other processes
     // mapping the same file (or children); if not shared (private), each
-    // process has its own mapping; if the mapping is writable, the changes
-    // are not reflected to the underlying file. See the discussion of
+    // process has its own mapping. Changes in writable, private mappings are
+    // not reflected to the underlying file. See the discussion of
     // MAP_PRIVATE vs MAP_SHARED in the mmap(2) manual page.
     bool shared = true;
 
@@ -127,13 +125,13 @@ class MemoryMapping : boost::noncopyable {
                          off_t length=-1,
                          Options options=Options());
 
-  MemoryMapping(MemoryMapping&&);
+  MemoryMapping(MemoryMapping&&) noexcept;
 
   ~MemoryMapping();
 
   MemoryMapping& operator=(MemoryMapping);
 
-  void swap(MemoryMapping& other);
+  void swap(MemoryMapping& other) noexcept;
 
   /**
    * Lock the pages in memory
@@ -157,6 +155,7 @@ class MemoryMapping : boost::noncopyable {
    * Advise the kernel about memory access.
    */
   void advise(int advice) const;
+  void advise(int advice, size_t offset, size_t length) const;
 
   /**
    * A bitwise cast of the mapped bytes as range of values. Only intended for
@@ -229,7 +228,7 @@ class MemoryMapping : boost::noncopyable {
   MutableByteRange data_;
 };
 
-void swap(MemoryMapping&, MemoryMapping&);
+void swap(MemoryMapping&, MemoryMapping&) noexcept;
 
 /**
  * A special case of memcpy() that always copies memory forwards.
@@ -249,5 +248,3 @@ void alignedForwardMemcpy(void* dest, const void* src, size_t size);
 void mmapFileCopy(const char* src, const char* dest, mode_t mode = 0666);
 
 }  // namespace folly
-
-#endif /* FOLLY_MEMORYMAPPING_H_ */