From 1590e0d2a51bce1fe9864d93f7b6fa89221e51ac Mon Sep 17 00:00:00 2001 From: orxfun Date: Wed, 28 Aug 2024 10:59:46 +0200 Subject: [PATCH] reserve_maximum_concurrent_capacity_fill_with is implemented --- Cargo.toml | 2 +- src/concurrent_pinned_vec.rs | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 50dfe43..43a1bad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "orx-pinned-vec" -version = "3.6.0" +version = "3.7.0" edition = "2021" authors = ["orxfun "] description = "`PinnedVec` trait defines the interface for vectors which guarantee that elements added to the vector are pinned to their memory locations unless explicitly changed." diff --git a/src/concurrent_pinned_vec.rs b/src/concurrent_pinned_vec.rs index e2f8a67..eab554b 100644 --- a/src/concurrent_pinned_vec.rs +++ b/src/concurrent_pinned_vec.rs @@ -148,6 +148,24 @@ pub trait ConcurrentPinnedVec { new_maximum_capacity: usize, ) -> usize; + /// Increases the `maximum_capacity` to the `new_maximum_capacity`. + /// If capacity extension leads to allocation, allocated memory is filled with the given function. + /// + /// # Safety + /// + /// This method is unsafe since the concurrent pinned vector might contain gaps. + /// The vector must be gap-free while increasing the maximum capacity. + /// + /// This method can safely be called if entries in all positions `0..len` are written. + unsafe fn reserve_maximum_concurrent_capacity_fill_with( + &mut self, + len: usize, + new_maximum_capacity: usize, + fill_with: F, + ) -> usize + where + F: Fn() -> T; + // &mut self /// Sets the length of the underlying pinned vector to the given `len`.