Skip to content

Commit

Permalink
Merge pull request #32 from orxfun/reserve-filled-capacity
Browse files Browse the repository at this point in the history
reserve_maximum_concurrent_capacity_fill_with is implemented
  • Loading branch information
orxfun authored Aug 28, 2024
2 parents 1539929 + 1590e0d commit c52b4f0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "orx-pinned-vec"
version = "3.6.0"
version = "3.7.0"
edition = "2021"
authors = ["orxfun <[email protected]>"]
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."
Expand Down
18 changes: 18 additions & 0 deletions src/concurrent_pinned_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,24 @@ pub trait ConcurrentPinnedVec<T> {
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<F>(
&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`.
Expand Down

0 comments on commit c52b4f0

Please sign in to comment.