-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Thread safe `Clone` method is implemented. * `Index` and `IndexMut` traits are implemented for `usize` indices. * Due to possibly fragmented nature of the underlying pinned vec, and since we cannot return a reference to a temporarily created collection, currently index over a range is not possible. This would be possible with `IndexMove` (see rust-lang/rfcs#997). * Debug trait implementation is made mode convenient, revealing the current len and capacity in addition to the elements. * Upgraded dependencies to pinned-vec (3.7) and pinned-concurrent-col (2.6) versions. * Tests are extended: * concurrent clone is tested. * in addition to concurrent push & read, safety of concurrent extend & read is also tested. * boxcar::Vec is added to the benchmarks.
- Loading branch information
Showing
23 changed files
with
683 additions
and
353 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use crate::ConcurrentVec; | ||
use orx_concurrent_option::ConcurrentOption; | ||
use orx_fixed_vec::IntoConcurrentPinnedVec; | ||
|
||
impl<T, P> Clone for ConcurrentVec<T, P> | ||
where | ||
P: IntoConcurrentPinnedVec<ConcurrentOption<T>>, | ||
T: Clone, | ||
{ | ||
fn clone(&self) -> Self { | ||
let core = unsafe { self.core.clone_with_len(self.len()) }; | ||
Self { core } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use crate::ConcurrentVec; | ||
use orx_concurrent_option::ConcurrentOption; | ||
use orx_fixed_vec::IntoConcurrentPinnedVec; | ||
use std::fmt::Debug; | ||
|
||
const ELEM_PER_LINE: usize = 8; | ||
|
||
impl<T, P> Debug for ConcurrentVec<T, P> | ||
where | ||
P: IntoConcurrentPinnedVec<ConcurrentOption<T>>, | ||
T: Debug, | ||
{ | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
let len = self.len(); | ||
let capacity = self.capacity(); | ||
|
||
write!(f, "ConcurrentVec {{")?; | ||
write!(f, "\n len: {},", len)?; | ||
write!(f, "\n capacity: {},", capacity)?; | ||
write!(f, "\n data: [,")?; | ||
for i in 0..len { | ||
if i % ELEM_PER_LINE == 0 { | ||
write!(f, "\n ")?; | ||
} | ||
match self.get(i) { | ||
Some(x) => write!(f, "{:?}, ", x)?, | ||
None => write!(f, "*, ")?, | ||
} | ||
} | ||
write!(f, "\n ],")?; | ||
write!(f, "\n}}") | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn debug() { | ||
let vec = ConcurrentVec::new(); | ||
vec.extend([0, 4, 1, 2, 5, 6, 32, 5, 1, 121, 2, 42]); | ||
let dbg_str = format!("{:?}", &vec); | ||
assert_eq!(dbg_str, "ConcurrentVec {\n len: 12,\n capacity: 12,\n data: [,\n 0, 4, 1, 2, 5, 6, 32, 5, \n 1, 121, 2, 42, \n ],\n}"); | ||
} | ||
} |
Oops, something went wrong.