From de56f6704606912b096b7c56bacb3e339cae15e3 Mon Sep 17 00:00:00 2001 From: Avril Date: Mon, 17 Oct 2022 21:56:03 +0100 Subject: [PATCH] MappedFile::shared() is now unwind-safe. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fortune for mapped-file's current commit: Half blessing − 半吉 --- src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 64d57b6..a5bf66a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -124,6 +124,8 @@ impl MappedFile { /// This essentially creates s "sender" `tx`, and "receiver" `rx` mapping over the same data. /// The sender is *write only*, and the receiver is *read only*. /// + /// When **both** of the mappings have been uunmapped (when each `MappedFile` has been dropped,) the inner value `file` is then dropped. + /// /// # Sharing modes /// `B` is used for the counter over the file handle `T`. Currently it can be /// * `buffer::Shared` - A `Send`able mapping, use this for concurrent processing. @@ -131,7 +133,7 @@ impl MappedFile { /// /// # Note /// `len` **must** be a multiple of the used page size (or hugepage size, if `flags` is set to use one) for this to work. - pub fn try_new_buffer>(file: T, len: usize, flags: impl flags::MapFlags) -> Result<(MappedFile, MappedFile), TryNewError> + pub fn shared>(file: T, len: usize, flags: impl flags::MapFlags) -> Result<(MappedFile, MappedFile), TryNewError> { Self::try_new_buffer_raw::(file, len, None, false, flags) }