diff --git a/Cargo.toml b/Cargo.toml index 74215c2f..fa55e65d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "skl" -version = "0.11.2" +version = "0.11.4" edition = "2021" rust-version = "1.56.0" repository = "https://github.com/al8n/skl" diff --git a/src/lib.rs b/src/lib.rs index 2e2adc60..064762a6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,9 +30,10 @@ pub use options::{MmapOptions, OpenOptions}; mod types; pub use types::*; -pub use rarena_allocator::{Arena, Error as ArenaError}; - +pub use either; pub use map::{AllVersionsIter, SkipMap}; +pub use rarena_allocator::{Arena, Error as ArenaError}; +pub use ux2::{u27, u5}; pub use ux2::{u27, u5}; diff --git a/src/map.rs b/src/map.rs index a0d7d428..adc9e6b3 100644 --- a/src/map.rs +++ b/src/map.rs @@ -287,7 +287,7 @@ impl NodePtr { /// /// - The caller must ensure that the node is allocated by the arena. /// - The caller must ensure that the offset is less than the capacity of the arena and larger than 0. - unsafe fn cas_next_offset_weak( + unsafe fn cas_next_offset( &self, arena: &Arena, idx: usize, @@ -296,11 +296,10 @@ impl NodePtr { success: Ordering, failure: Ordering, ) -> Result { - #[cfg(not(feature = "unaligned"))] self .tower(arena, idx) .next_offset - .compare_exchange_weak(current, new, success, failure) + .compare_exchange(current, new, success, failure) } } @@ -1864,7 +1863,7 @@ impl SkipMap { } } - match prev.cas_next_offset_weak( + match prev.cas_next_offset( &self.arena, i, next.offset, diff --git a/src/map/api.rs b/src/map/api.rs index 924af42a..43a18551 100644 --- a/src/map/api.rs +++ b/src/map/api.rs @@ -3,7 +3,7 @@ use ux2::u27; use super::*; -impl SkipMap { +impl SkipMap { /// Create a new skipmap with default options. /// /// **Note:** The capacity stands for how many memory allocated, diff --git a/src/map/tests.rs b/src/map/tests.rs index 3750f3a7..1d317fc0 100644 --- a/src/map/tests.rs +++ b/src/map/tests.rs @@ -5,6 +5,7 @@ use std::format; use std::sync::Arc; +use rarena_allocator::Freelist; #[cfg(feature = "std")] use wg::WaitGroup; @@ -180,12 +181,30 @@ fn full_in(l: impl FnOnce(usize) -> SkipMap) { #[test] fn test_full() { - run(|| full_in(|n| SkipMap::with_options(Options::new().with_capacity(n as u32)).unwrap())) + run(|| { + full_in(|n| { + SkipMap::with_options( + Options::new() + .with_capacity(n as u32) + .with_freelist(Freelist::None), + ) + .unwrap() + }) + }) } #[test] fn test_full_unify() { - run(|| full_in(|n| SkipMap::with_options(UNIFY_TEST_OPTIONS.with_capacity(n as u32)).unwrap())) + run(|| { + full_in(|n| { + SkipMap::with_options( + UNIFY_TEST_OPTIONS + .with_capacity(n as u32) + .with_freelist(Freelist::None), + ) + .unwrap() + }) + }) } #[test] @@ -202,7 +221,13 @@ fn test_full_map_mut() { .read(true) .write(true); let map_options = MmapOptions::default(); - SkipMap::map_mut(p, open_options, map_options).unwrap() + SkipMap::map_mut_with_options( + p, + Options::new().with_freelist(Freelist::None), + open_options, + map_options, + ) + .unwrap() }); }) } @@ -213,7 +238,8 @@ fn test_full_map_anon() { run(|| { full_in(|n| { let map_options = MmapOptions::default().len(n as u32); - SkipMap::map_anon(map_options).unwrap() + SkipMap::map_anon_with_options(Options::new().with_freelist(Freelist::None), map_options) + .unwrap() }); }) } @@ -224,7 +250,8 @@ fn test_full_map_anon_unify() { run(|| { full_in(|n| { let map_options = MmapOptions::default().len(n as u32); - SkipMap::map_anon_with_options(TEST_OPTIONS, map_options).unwrap() + SkipMap::map_anon_with_options(Options::new().with_freelist(Freelist::None), map_options) + .unwrap() }); }) } @@ -2265,8 +2292,7 @@ fn test_reopen_mmap() { let open_options = OpenOptions::default() .create(Some(ARENA_SIZE as u32)) .read(true) - .write(true) - .lock_exclusive(true); + .write(true); let map_options = MmapOptions::default(); let l = SkipMap::map_mut(&p, open_options, map_options).unwrap(); for i in 0..1000 { @@ -2275,12 +2301,9 @@ fn test_reopen_mmap() { l.flush().unwrap(); } - let open_options = OpenOptions::default() - .read(true) - .lock_shared(true) - .shrink_on_drop(true); + let open_options = OpenOptions::default().read(true).shrink_on_drop(true); let map_options = MmapOptions::default(); - let l = SkipMap::map(&p, open_options, map_options, 0).unwrap(); + let l = SkipMap::::map(&p, open_options, map_options, 0).unwrap(); assert_eq!(1000, l.len()); for i in 0..1000 { let k = key(i); @@ -2305,8 +2328,7 @@ fn test_reopen_mmap2() { let open_options = OpenOptions::default() .create(Some(ARENA_SIZE as u32)) .read(true) - .write(true) - .lock_shared(true); + .write(true); let map_options = MmapOptions::default(); let l = SkipMap::map_mut_with_comparator(&p, open_options, map_options, Ascend).unwrap(); let mut data = (0..1000).collect::>();