Skip to content

Commit

Permalink
Make lock and unlock &self.
Browse files Browse the repository at this point in the history
Fixes #74
  • Loading branch information
timvisee authored May 9, 2023
1 parent 9970820 commit bd52d2c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,15 +646,15 @@ impl Mmap {
///
/// See [mlock()](https://man7.org/linux/man-pages/man2/mlock.2.html) map page.
#[cfg(unix)]
pub fn lock(&mut self) -> Result<()> {
pub fn lock(&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<()> {
pub fn unlock(&self) -> Result<()> {
self.inner.unlock()
}
}
Expand Down Expand Up @@ -837,15 +837,15 @@ impl MmapRaw {
///
/// See [mlock()](https://man7.org/linux/man-pages/man2/mlock.2.html) map page.
#[cfg(unix)]
pub fn lock(&mut self) -> Result<()> {
pub fn lock(&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<()> {
pub fn unlock(&self) -> Result<()> {
self.inner.unlock()
}
}
Expand Down Expand Up @@ -1105,15 +1105,15 @@ impl MmapMut {
///
/// See [mlock()](https://man7.org/linux/man-pages/man2/mlock.2.html) map page.
#[cfg(unix)]
pub fn lock(&mut self) -> Result<()> {
pub fn lock(&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<()> {
pub fn unlock(&self) -> Result<()> {
self.inner.unlock()
}
}
Expand Down Expand Up @@ -1728,7 +1728,7 @@ mod test {
.unwrap();
file.set_len(128).unwrap();

let mut mmap = unsafe { Mmap::map(&file).unwrap() };
let mmap = unsafe { Mmap::map(&file).unwrap() };
#[cfg(target_os = "linux")]
assert!(!is_locked());

Expand Down

0 comments on commit bd52d2c

Please sign in to comment.