Skip to content

Commit

Permalink
MmapRaw: Add some functions to catch up with MmapMut.
Browse files Browse the repository at this point in the history
  • Loading branch information
diwic authored Nov 9, 2022
1 parent 7705bdd commit 0f1c41e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,30 @@ impl MmapRaw {
pub fn flush_async_range(&self, offset: usize, len: usize) -> Result<()> {
self.inner.flush_async(offset, len)
}

/// Advise OS how this memory map will be accessed. Only supported on Unix.
///
/// See [madvise()](https://man7.org/linux/man-pages/man2/madvise.2.html) map page.
#[cfg(unix)]
pub fn advise(&self, advice: Advice) -> Result<()> {
self.inner.advise(advice)
}

/// Lock the whole memory map into RAM. Only supported on Unix.
///
/// See [mlock()](https://man7.org/linux/man-pages/man2/mlock.2.html) map page.
#[cfg(unix)]
pub fn lock(&mut self) -> Result<()> {
self.inner.lock()
}

/// Unlock the whole memory map. Only supported on Unix.
///
/// See [munlock()](https://man7.org/linux/man-pages/man2/munlock.2.html) map page.
#[cfg(unix)]
pub fn unlock(&mut self) -> Result<()> {
self.inner.unlock()
}
}

impl fmt::Debug for MmapRaw {
Expand Down

0 comments on commit 0f1c41e

Please sign in to comment.